Java-unit-2-unsolved
Java-unit-2-unsolved
Unsolved programs:
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);
}
}
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);
}
}
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);
}
}
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” );
}
}