|
Thank you for that 2nd problem! Thank you thank you!!!
I tried this with the first problem. I can certainly give what the problem is asking for but i just cant make one with Methods in it.
import java.io.*;
public class Change
{
public static void main(String args[]) throws IOException
{
BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
String input;
double cost=0;
double tax=0;
double payment=0;
double getCost=0;
double getTax=0;
double getPayment=0;
System.out.print("Please enter Item Cost:");
input=x.readLine();
cost=Double.parseDouble(input);
public void getTax(){tax = cost*getTax;
}
public void getCost(){ = cost+tax;
}
System.out.println("The cost of the item with included sales tax is "+getCost);
System.out.println("Please enter the amount of your payment");
input=x.readLine();
payment=Double.parseDouble(input);
if (payment<getCost)
System.out.println("Sorry but your payment is not enough");
getPayment = payment-getCost;
System.out.println("The original cost of the item is "+cost);
System.out.println("The sales tax is 6%");
System.out.println("The item with added tax is no priced "+getCost);
System.out.println("Your change is "+getPayment);
}
}
|