View Single Post
  #3 (permalink)  
Old 07-23-2008, 08:41 AM
saculellav saculellav is offline
Member
 
Join Date: Jul 2008
Location: Philippines!
Posts: 4
saculellav is on a distinguished road
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);
}
}
Reply With Quote