0% found this document useful (0 votes)
5 views2 pages

Grade10 Java Assignments

Uploaded by

studyaccdev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Grade10 Java Assignments

Uploaded by

studyaccdev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

// Grade 10 Java Assignments (Assignment 1 to 14 excluding 11 and 12)

// Created by Devansh & ChatGPT

import java.util.*;

// Assignment 1 HCF using Euclid's Method


class HCF_Euclid
{
void PrintHCF(int x, int y)
{
int a = x;
int b = y;
while (b != 0)
{
int temp = b;
b = a % b;
a = temp; // Keep updating with remainder
}
System.out.println("HCF = " + a); // Final answer
}

public static void main(String[] args)


{
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
new HCF_Euclid().PrintHCF(x, y);
}
}

// Assignment 2 Cash Memo


class Sample
{
void product(int code, float price, float quantity)
{
float total = price * quantity;
float discount = total * 0.12f;
float net = total - discount;

// Display all product info


System.out.println("Code: " + code);
System.out.println("Total: " + total);
System.out.println("Discount: " + discount);
System.out.println("Net Payable: " + net);
}

public static void main(String[] args)


{
new Sample().product(1001, 50f, 3);
}
}

// Assignment 3 Distance Calculation


class DistanceCalc
{
double distance(double u, double t, double a)
{
return (u * t) + (0.5 * a * t * t);
}

public static void main(String[] args)


{
Scanner sc = new Scanner(System.in);
double u = sc.nextDouble();
double t = sc.nextDouble();
double a = sc.nextDouble();

DistanceCalc obj = new DistanceCalc();


System.out.println("Distance = " + obj.distance(u, t, a));
}
}

// (Content continues...)

You might also like