0% found this document useful (0 votes)
9 views

Java-unit-2-unsolved

Uploaded by

jitendra.bhu82
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Java-unit-2-unsolved

Uploaded by

jitendra.bhu82
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

II.

Unsolved programs:

A1. int a = 20, b = 15, c;


c = (a * a + b * b) / (a - b);
System.out.println(“Value of c = ” + c);
A2. \\Calculation of gross salary.
class Salary
{
public static void main( String args[])
{
int b_sal = 8600, da, hra, cta, gr_sal;
da = ( b_sal * 20 ) / 100;
hra = ( b_sal * 10 ) / 100;
cta = ( b_sal * 12 )/ 100;
gr_sal = b_sal + da + hra + cta;
System.out.println(“Basic Salary : ” + b_sal);
System.out.println(“Gross Salary : ” + gr_sal);
}
}

A3. \\Accumulated interest

class Si
{
public static void main( String args[])
{
int P=5000, si;
si = (P*10)/100;
System.out.println (“Interest for the first year : ” + si);
P = P+si;
si = (P*10)/100;
System.out.println(“Interest for the second year : ” + si);
P = P+si;
si = (P*10)/100;
System.out.println(“Interest for the third year : ” + si);
}
}

A4. \\successive discount 20% and 10%

class Discount
{
public static void main( int price)
{
int sel_price, discnt;
discnt = (price*20)/100;
price = price – discnt;
discnt = (price * 10)/100;
sel_price = price – discnt;
System.out.println (“Selling price is : ” + sel_price);
}
}

A5. \\swapping the values

class swap
{
public static void main( int a, int b)
{
System.out.println (“ values before swapping: a = ” + a + “ , b = ” + b)
a = a + b;
b = a – b;
a = a – b;
System.out.println (“ values after swapping: a = ” + a + “ , b = ” + b);
}
}

A6. \\Temperature conversion from calsius to Fahrenheit.

class Temp
{
public static void main( double tc)
{
System.out.println (“ Temperature in degrees calsius :” + tc)
double tf = 0.0;
tf = tc * 9 / 5 + 32;
System.out.println (“ Temperature in degrees Fahrenheit :” + tf );
if (tf > 98.6)
System.out.println (“Fever” );
else
System.out.println (“Normal” );
}
}

You might also like