A little unsure of what your asking. Are you wanting the price of the car to be subtracted? It's a bit hard to tell what you mean, as this looks like a short homework/assignment piece. Is it? That would help to know.
import java.util.*; // Scanner Class
class exercise99
{
public static void main()
{
// Define and create a Scanner object
Scanner inputLine = new Scanner(System.in);
// Define other variables required
float caryear=0, rate=0, carprice=0;
// Display a heading on the screen
System.out.println ("Depreciation calculator");
System.out.println ("==============================");
System.out.println ();
// Ask the user to enter car price
System.out.print ("Please enter car year: ");
caryear = inputLine.nextFloat();
System.out.print ("Please enter car price: ");
carprice = inputLine.nextFloat();
//ask the user to enter car year
//First year
if (caryear == 1 && (carprice <=25000 ))
{
rate = 30;
}
if (caryear == 1 && (carprice <= 25000) && (carprice >=45000 ))
{
rate = 25;
}
if (caryear == 1 && (carprice <= 45000))
{
rate = 20;
}
//Second year and beyond
if (caryear >=2 && (carprice <=25000 ))
{
rate = 15;
}
if (caryear >=2 && (carprice <= 25000) && (carprice >=45000 ))
{
rate = 12;
}
if (caryear >=2 && (carprice <= 45000))
{
rate = 10;
}
carprice = carprice - rate;
//Calculation for
// Display the circle area
System.out.println ("This is the caculated car price:" + carprice );
}
}
// End program
float X = .5, Y=100, Z = 0;
Z = Y * X;
System.out.println("Half of 100 is: " + Z);
import java.util.*; // Scanner Class
class exercise99
{
public static void main()
{
// Define and create a Scanner object
Scanner inputLine = new Scanner(System.in);
// Define other variables required
float caryear=0, rate=0, carprice=0;
// Display a heading on the screen
System.out.println ("Depreciation calculator");
System.out.println ("==============================");
System.out.println ();
// Ask the user to enter car price
System.out.print ("Please enter car year: ");
caryear = inputLine.nextFloat();
System.out.print ("Please enter car price: ");
carprice = inputLine.nextFloat();
//ask the user to enter car year
//First year
if (caryear == 1 && (carprice <=25000 ))
{
rate = [B].3[/B];
}
if (caryear == 1 && (carprice <= 25000) && (carprice >=45000 ))
{
rate = [B].25[/B];
}
if (caryear == 1 && (carprice <= 45000))
{
rate = [B].2[/B];
}
//Second year and beyond
if (caryear >=2 && (carprice <=25000 ))
{
rate = [B].15[/B];
}
if (caryear >=2 && (carprice <= 25000) && (carprice >=45000 ))
{
rate = [B].12[/B];
}
if (caryear >=2 && (carprice <= 45000))
{
rate = [B].1[/B];
}
carprice = carprice [B]*[/B] rate;
//Calculation for
// Display the circle area
System.out.println ("This is the caculated car price:" + carprice );
}
}
// End program