Joined
·
493 Posts
Hi there!
So basically I need to work minus a percentage off of a price! For some reason this really confused me and left me with this mess:
any help? D: D: D:
So basically I need to work minus a percentage off of a price! For some reason this really confused me and left me with this mess:
Code:
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
any help? D: D: D: