My first assignment is to develop a code that allows the user to input data for the distance in miles they wish to travel, the fuel efficiency, and the cost of gas. Then create a code in order to calculate the total cost of the trip.
I have all the code for all the input values but I'm having trouble with the equation itself. Java is not recognizing "/". I can't understand what I'm doing unless I need to add a bit more code for the equation to work.
import java.util.Scanner;
public class DrivingCost
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
System.out.print("Please enter your distance (miles): ");
Scanner t = new Scanner(System.in);
System.out.print("Please enter vehicle's fuel efficiency (mpg): ");
Scanner u = new Scanner(System.in);
System.out.print("Please enter the price per gallon (dollars): ");
String distanceInMiles = s.nextLine();
System.out.println("The distance (miles): " + distanceInMiles);
String fuelEfficiency = t.nextLine();
System.out.println("Fuel efficiency (mpg):" + fuelEfficiency);
String pricePerGallon = u.nextLine();
System.out.println("Price per gallon (dollars): " + pricePerGallon);
double tripCost = (distanceInMiles / fuelEfficiency) * pricePerGallon;
System.out.println("The trip cost (dollars): " + tripCost);
}
}
This is the error I keep recieving:
DrivingCost.java:32: error: bad operand types for binary operator '/'
double tripCost = (distanceInMiles / fuelEfficiency) * pricePerGallon;
^
You're doing Math operation on String, you can't, you need double type
Double.parseDouble(sc.nextLine()); reads a line and parse to a double (benefits : avoid return line error in general, good habit to have)
sc.nextDouble() reads directly for a double
Use only one Scanner per source
Have a good order between print and scanner asking
Scanner sc = new Scanner(System.in);
System.out.print("Please enter your distance (miles): ");
String distanceInMiles = Double.parseDouble(sc.nextLine());
System.out.println("The distance (miles): " + distanceInMiles);
System.out.print("Please enter vehicle's fuel efficiency (mpg): ");
String fuelEfficiency = Double.parseDouble(sc.nextLine());
System.out.println("Fuel efficiency (mpg):" + fuelEfficiency);
System.out.print("Please enter the price per gallon (dollars): ");
String pricePerGallon = Double.parseDouble(sc.nextLine());
System.out.println("Price per gallon (dollars): " + pricePerGallon);
double tripCost = (distanceInMiles / fuelEfficiency) * pricePerGallon;
System.out.println("The trip cost (dollars): " + tripCost);
You are trying to do calculations with strings. You have to parse doubles out of your string inputs. Just change your equation line to this:
double tripCost = (Double.valueOf(distanceInMiles) / Double.valueOf(fuelEfficiency)) * Double.valueOf(pricePerGallon);
P.S. Proper input validation would be a good improvement. In case user provide incorrect input. Also, as mentioned in the comments there is no need to use multiple Scanners. One will be enough.
You can get distanceInMiles, fuelEfficiency and pricePerGallon in double using s.nextDouble().
After that you should be able to perform double operation on these variables.
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
System.out.print("Please enter your distance (miles): ");
double distanceInMiles = s.nextDouble();
System.out.println("The distance (miles): " + distanceInMiles);
System.out.print("Please enter vehicle's fuel efficiency (mpg): ");
double fuelEfficiency = s.nextDouble();
System.out.println("Fuel efficiency (mpg):" + fuelEfficiency);
System.out.print("Please enter the price per gallon (dollars): ");
double pricePerGallon = s.nextDouble();
System.out.println("Price per gallon (dollars): " + pricePerGallon);
double tripCost = (distanceInMiles / fuelEfficiency) * pricePerGallon;
System.out.println("The trip cost (dollars): " + tripCost);
}
Related
I am writing a program that takes user input of food order and amount paid and prompts the amount of currency units to be doled out. If the bill is 30.89 and the after tax bill is 31.89 than the expected result is:
$20: 1
$10: 1
$5: 0
.. and so on till the last penny.
So basically i tried to find the minimum bills needed to give for change but I kept getting a really long decimal instead of integers. I tried formatting it but it wont work. Do I have to change my variable conventions (e.g int to double or double to int??) if so which ones?
Here is what I have implemented:
Welcome to Sonia Shawarma!
Price List
Cheeseburger: $4.69
Falafel in a pita: $6.00
Poutine: $4.50
import java.util.Scanner;
public class PointOfSale
{
public static void main(String [] args)
//declaring variables
int burgers;
int poutines;
int falafels;
double burger = 4.69;
double poutine = 4.50;
double falafel = 6.00;
double item1;
double item2;
double item3;
double totalbefore_tax;
final double TAX;
double tax_total;
double total_final;
double rounded_final;
double money_paid;
int twenties ;
int tens;
int fives;
int toonies;
int loonies;
double quarters;
double dimes;
double nickels;
double change1;
double change2;
double amount_bills20;
double amount_bills10;
double amount_bills5;
double dollars2;
double dollars1;
double cents25;
double cents10;
double cents5;
String date1;
String cashier1;
Scanner input = new Scanner(System.in);
System.out.println("Welcome to Sonia Shawarma!");
System.out.println("Price List");
System.out.println("Cheeseburger: $4.69");
System.out.println("Falafel in a pita: $6.00");
System.out.println("Poutine: $4.50");
//prompt user for number cheeseburgers,poutines,fries
System.out.println("Enter the number of Cheeseburgers:");
burgers = input.nextInt();
System.out.println("Enter the number of Falafels:");
falafels = input.nextInt();
System.out.println("Enter the number of Poutines:");
poutines = input.nextInt();
//calculating
item1 = (burger*burgers);
item2 = (falafel*falafels);
item3 = (poutine*poutines);
totalbefore_tax = (item1+(item2)+(item3));
TAX = 0.13;
tax_total = totalbefore_tax*TAX;
total_final = totalbefore_tax*1.13;
rounded_final = 0.05*(Math.round(total_final/0.05));
//total
System.out.format("%-5s%-3.2f\n", "Total before tax: ",totalbefore_tax);
System.out.format("%-5s%-3.2f\n", "Tax:", tax_total);
System.out.format("%-5s%-3.2f\n","Final total:", rounded_final);
System.out.format("%-5s%-3.2f\n", "Please pay:", rounded_final);
//prompt user for twenties to nickels
System.out.println("Enter the number of $20:");
twenties = input.nextInt();
System.out.println("Enter the number of $10:");
tens = input.nextInt();
System.out.println("Enter the number of $5:");
fives = input.nextInt();
System.out.println("Enter the number of Toonies($2):");
toonies = input.nextInt();
System.out.println("Enter the number of Loonies($1):");
loonies = input.nextInt();
System.out.println("Enter the number of Quarters($0.25):");
quarters = input.nextDouble();
System.out.println("Enter the number of Dimes($0.10):");
dimes = input.nextDouble();
System.out.println("Enter the number of Nickels($0.05):");
nickels = input.nextDouble();
//prompt money paid
System.out.println("Customer paid:");
money_paid = input.nextDouble();
change1 = money_paid - rounded_final;
System.out.format("%-5s%-3.2f\n","The change is:", change1);
change2 = (change1*100);
System.out.println("The minimum number of bills or coins is:");
//calculating minumum change
amount_bills20 = change2/2000;
change2 = change2%2000;
amount_bills10 = change2/1000;
change2 = change2%1000;
amount_bills5 = change2/500;
change2 = change2%500;
dollars2 = change2/200;
change2 = change2%200;
dollars1 = change2/100;
change2 = change2%100;
cents25 = change2/25;
change2 = change2%25;
cents10 = change2/10;
change2 = change2%10;
cents5 = change2/5;
change2 = change2%5;
//minimum number of bills needed
System.out.println("$20:" + amount_bills20);
System.out.println("$10:" + amount_bills10);
System.out.println("$5:" + amount_bills5);
System.out.println("Toonies:" + dollars2);
System.out.println("Loonies:" + dollars1);
System.out.println("Quarters:" + cents25);
System.out.println("Dimes:" + cents10);
System.out.println("Nickels:" + cents5);
System.out.println("Printing receipt...");
The output i get is Welcome to Sonia Shawarma!
Price List
Cheeseburger: $4.69
Falafel in a pita: $6.00
Poutine: $4.50
Enter the number of Cheeseburgers:
[2]
Enter the number of Falafels:
[1]
Enter the number of Poutines:
[1]
Total before tax: 19.88
Tax: 2.58
Final total:22.45
Please pay:22.45
Enter the number of $20:
[1]
Enter the number of $10:
[1]
Enter the number of $5:
[DrJava Input Box]
Enter the number of Toonies($2):
[DrJava Input Box]
Enter the number of Loonies($1):
[DrJava Input Box]
Enter the number of Quarters($0.25):
[DrJava Input Box]
Enter the number of Dimes($0.10):
[DrJava Input Box]
Enter the number of Nickels($0.05):
[DrJava Input Box]
Customer paid:
[30.00]
The change is:7.55
The minimum number of bills or coins is:
$20:0.3774999999999999
$10:0.7549999999999998
$5:1.5099999999999996
Toonies:1.2749999999999988
Loonies:0.5499999999999977
Quarters:2.199999999999991
Dimes:0.49999999999997724
Nickels:0.9999999999999545
Printing receipt...
Sonia Shawarma
If you want to work with double, you need to work with DecimalFormat to restrict the decimal fields as explained in: How to round a number to n decimal places in Java
DecimalFormat df = new DecimalFormat("#.##");
df.setRoundingMode(RoundingMode.CEILING);
System.out.println((total_bill/20));
System.out.println(df.format(total_bill/20));
output:
1.8829999999999998 and 1.89
The other part is that your number of notes is decimal, which ofcourse is not acceptable. Since they are double, you need to cast them into int to get a whole number
double total_bill = new Double(21.6643);
System.out.println("20$ notes:" +(int)total_bill/20);
// casting to int gives the quotient integer. Output is 20$ notes:1
System.out.println("Remainder:" + df.format(total_bill%20));
//Output is: Remainder:1.664.
You then use this logic on all other notes and coins where the remainder becomes your total as you were doing or use a loop.
For the assignment this may be acceptable but in real world scenarios, you may need to use BigDecimal instead of double. And as always, stackoverflow has a wonderful post for that: Double vs. BigDecimal?.
However BigDecimal doesnt overload the normal math operators and has functions for all operations:
//retpre : is a BigDecimal - Total cash to return
System.out.println("20$ notes: " + retpre.divideToIntegralValue(new BigDecimal("20")).intValue());
BigDecimal tens =retpre.remainder(new BigDecimal("20"),mc);
//mc is MathContext to define precision and rounding
Assignment is to:
Display any welcome message at the top of the output screen
Create variables to hold the values for the price of a cup of lemonade.
Display the price per glass.
Ask the user for their name, and store it as a String object. Refer to the user by name, whenever you can.
Ask the user how many glasses of lemonade they would like to order. Save this as a variable with the appropriate data type.
Store the San Diego tax rate of 8% as a constant variable in your program.
Calculate the subtotal, total tax, and total price, and display it on the screen.
Ask the user how they would like to pay for the lemonade, and save the input as a char variable.
Ask the user to enter either 'm' for money, 'c' for credit card, or 'g' for gold
Using the DecimalFormat class, make all currency data printed to the screen display 2 decimal places, and also a '$" sign.
Need help figuring out how to get tax rate of 8% as a constant variable in my program
that way I can calculate the subtotal, total tax, and total price, and display it on the screen
So far this is what I have:
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class FirstProgram {
public static void main(String[] args) {
double cost = 7.55;
double amount = 7.55;
final double CA_SALES_TAX = 0.08;
int tax, subtotal, total;
subtotal = (int) (amount * cost);
tax = (int) (subtotal * CA_SALES_TAX);
total = tax + subtotal;
Scanner input = new Scanner(System.in);
double fnum = 7.55, tax1 = fnum * 0.08, answer = tax1 + fnum;
System.out.println("Welcome to the best Lemonade you'll ever taste! ");
System.out.println("My lemonade would only cost you a measly: $" + amount);
System.out.println("What is your name?");
String first_name;
first_name = input.nextLine();
System.out.println("Hi " +first_name+ ", how many glasses of lemonade would you like?");
fnum = input.nextDouble();
System.out.println("Subtotal: $" + (amount * fnum));
System.out.println("Tax: $" + (tax1 * CA_SALES_TAX));
tax1 = input.nextDouble();
Any help is appreciated
It looks like you already have the sales tax set as constant that is what the "final" keyword is being used for. As for your code i see some redundancies and am not sure as to why you are casting to integers. I made some mods for what I think you want it to do.
public static void main(String[] args) {
double cost = 7.55;
final double CA_SALES_TAX = 0.08;
double subtotal,tax,total;
Scanner input = new Scanner(System.in);
System.out.println("Welcome to the best Lemonade you'll ever taste! ");
System.out.println("My lemonade would only cost you a measly: $" + cost);
System.out.println("What is your name?");
String first_name = input.nextLine();
System.out.println("Hi " +first_name+ ", how many glasses of lemonade would you like?");
int fnum = input.nextInt();
//calc subtotal, tax, total
subtotal = fnum * cost;
tax = subtotal *CA_SALES_TAX;
total = tax + subtotal;
// print them all out
System.out.println("Subtotal: $" + (subtotal));
System.out.println("Tax: $" + (tax));
System.out.println("Total Price: $" + (total));
}
Since premium gasoline is more expensive than regular, I need to calculate gas mileage one must get on premium gasoline to make up the cost differential between that and regular gasoline. This value is represented by the gasmileageRequired variable.
Question: Am I calculating the gasmileageRequired variable correctly?
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Scanner;
public class GasMileage {
public static void main(String[] args) {
//Variable declarations
Scanner scan = new Scanner(System.in);
NumberFormat numFmt = new DecimalFormat("##.###");
NumberFormat costFmt = DecimalFormat.getCurrencyInstance();
double tankSize = 0;
final double regularCost;
final double premiumCost;
double regularGasMileage = 0;
//User enters gas tank size
System.out.print("What is the size of your gas tank? (in gallons) ");
tankSize = scan.nextDouble();
//User enters price of regular gasoline
System.out.print("What is the cost of regular gasoline per gallon? (in $) ");
regularCost = scan.nextDouble();
//User enters price of premium gasoline
System.out.print("What is the cost of premium gasoline per gallon? (in $) ");
premiumCost = scan.nextDouble();
//User enters cars' gas mileage
System.out.print("What is your cars' gas mileage on regular gasoline? (miles/gallon) ");
regularGasMileage = scan.nextDouble();
//Variable declarations
double totalregularCost = regularCost * tankSize;
double totalpremiumCost = premiumCost * tankSize;
double costDifference = totalpremiumCost - totalregularCost;
double gasmileageRequired = regularGasMileage + (premiumCost/costDifference);
scan.close();
//Begin output
System.out.println("\nGas tank size: " + tankSize + " gallons");
System.out.println("\nTotal cost of regular gasoline: " + costFmt.format(totalregularCost) + "\nGas mileage (regular): " + numFmt.format(regularGasMileage) + " miles/gallon");
System.out.println("\nTotal cost of premium gasoline: " + costFmt.format(totalpremiumCost) + "\nGas mileage required to make up for cost increase: " +
numFmt.format(gasmileageRequired) + " miles/gallon");
}
}
gasmilageRequired is being calculated correctly, yes. It should tell you how many MPG u would need to get in order to make up the price difference.
I'm in a programming class in high-school, and I was given an assignment to make a basic subtotal and top calculator, but I work at a restaurant, so it seemed a little pointless to make a calculator that only let you read in one food. So I tried to make it able to take in multiple food items and add them to one price variable. Sorry if some of this code may seem inefficient or redundant. It's only high-school of course.
The issue is, when I run it, it gets up to the asking if there was another food item the user would like to add, and when I type in "Yes" or "No", the program does nothing. Keeps running, but goes no further. Any explanations?
import java.text.NumberFormat;
import java.util.Scanner;
public class Price {
/**
* #param args
*/
public static void main(String[] args) {
final double taxRate = .0887; //8.87% Tax Rate
double tipRate;
int quantity1;
Scanner kb = new Scanner(System.in);
double subtotal, tax, tip, totalCost1, unitPrice1 = 0;
String done;
System.out.println ("How many of the first item did you get?: ");
quantity1 = kb.nextInt();
for (int i = 0; i < quantity1; i++)
{
System.out.println ("What was the price of that single item "+(i+1) + ": ");
unitPrice1 = kb.nextDouble();
System.out.println ("Was there another food item you'd like to add?: ");
done=kb.next();
while (done.equalsIgnoreCase("Yes"));
}
System.out.println ("What percent would you like to tip? (Formatted like 0.10 for 10%, 0.20 for 20%, etc.): ");
tipRate = kb.nextDouble();
subtotal= quantity1 * unitPrice1;
tax = subtotal * taxRate;
totalCost1 = subtotal + tax;
tip = totalCost1 * tipRate;
totalCost1 = totalCost1 + tip;
//Formatting
NumberFormat money = NumberFormat.getCurrencyInstance();
NumberFormat tipMoney = NumberFormat.getCurrencyInstance();
NumberFormat taxPercent = NumberFormat.getPercentInstance();
NumberFormat tipPercent = NumberFormat.getPercentInstance();
System.out.println ("Your total before tax is: " + money.format(subtotal));
System.out.println ("The tax is " + money.format(tax) + " at " + tipPercent.format(taxRate));
System.out.println ("The tip at " + tipPercent.format(tipRate) + " is " + tipMoney.format(tip));
}
}
You have an infinite loop here:
while (done.equalsIgnoreCase("Yes"));
Once you enter Yes, it will keep sitting there and doing nothing because the value of done is Yes and never changes.
Also your loop structure is a bit odd. Your outer for loop runs as many times as the quantity of the first item. But shouldn't you only be multiplying that number to the cost? Because you are either running the loop for as long as the number of items the user entered (by asking them up front) or you don't ask them the total number of items and simply ask them to enter Yes if they want to add more items; you can't really do both.
Your loop should probably look something like this:
String input = "Yes";
while(input.equalsIgnoreCase("Yes")) {
System.out.println ("How many of the first item did you get? ");
quantity1 = kb.nextInt();
System.out.println ("What was the price of that single item? ");
unitPrice1 = kb.nextDouble();
//total += unitPrice1 * quantity1 - you don't have this in your code, but this is where you would be calculating the running total
System.out.println("Was there another food item you'd like to add? ");
input = kb.next();
}
you need to exit for loop when user enters yes, so you can use label here like below:
outerloop:
for (int i = 0; i < quantity1; i++)
{
System.out.println ("What was the price of that single item "+(i+1) + ": ");
unitPrice1 = kb.nextDouble();
System.out.println ("Was there another food item you'd like to add?: ");
done=kb.next();
while (done.equalsIgnoreCase("Yes")){
break outerloop;
}
}
Your current code does not do anything inside the while loop if you don't enter yes. And if you enter yes it will be stuck in infinite loop because of your while loop. This is not the efficeint way of looping, but this code will have least change in your current code.
You're while loop is doing nothing, you had given it a condition, but it has no instruction.
Try something like this..(sorry for my rusty java)
'public static void main(String[] args) {
//variable declaration
bool running = true
final double taxRate = .0887; //8.87% Tax Rate
double tipRate;
int quantity1;
Scanner kb = new Scanner(System.in);
double subtotal, tax, tip, totalCost1, unitPrice1 = 0;
String done;
while(running = true){
System.out.println ("How many of the first item did you get?: ");
quantity1 = kb.nextInt();
for (int i = 0; i < quantity1; i++)
{
System.out.println ("What was the price of that single item "+(i+1) + ": ");
unitPrice1 = kb.nextDouble();
System.out.println ("Was there another food item you'd like to add?: ");
done=kb.next();
if(done.equalsIgnoreCase("No")){
running = false
//Allows you to break out of the while loop if the user does not want to add anything else
//DO NOT USE BREAK STATMENTS, IT IS A POOR PROGRAMMING PRACTICE.
};//end if
}//end for
}//end while
System.out.println ("What percent would you like to tip? (Formatted like 0.10 for 10%, 0.20 for 20%, etc.): ");
tipRate = kb.nextDouble();
//You should comment whats going on here
subtotal= quantity1 * unitPrice1;
tax = subtotal * taxRate;
totalCost1 = subtotal + tax;
tip = totalCost1 * tipRate;
totalCost1 = totalCost1 + tip;
//Formatting
NumberFormat money = NumberFormat.getCurrencyInstance();
NumberFormat tipMoney = NumberFormat.getCurrencyInstance();
NumberFormat taxPercent = NumberFormat.getPercentInstance();
NumberFormat tipPercent = NumberFormat.getPercentInstance();
//Output
System.out.println ("Your total before tax is: " + money.format(subtotal));
System.out.println ("The tax is " + money.format(tax) + " at " + tipPercent.format(taxRate));
System.out.println ("The tip at " + tipPercent.format(tipRate) + " is " + tipMoney.format(tip));
}//end main
I have some code which I find to keep giving me a dividing by 0 error.
It is suppose to calculate the monthly payment amount!
import java.io.*;
public class Bert
{
public static void main(String[] args)throws IOException
{
//Declaring Variables
int price, downpayment, tradeIn, months,loanAmt, interest;
double annualInterest, payment;
String custName, inputPrice,inputDownPayment,inputTradeIn,inputMonths, inputAnnualInterest;
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
//Get Input from User
System.out.println("What is your name? ");
custName = dataIn.readLine();
System.out.print("What is the price of the car? ");
inputPrice = dataIn.readLine();
System.out.print("What is the downpayment? ");
inputDownPayment = dataIn.readLine();
System.out.print("What is the trade-in value? ");
inputTradeIn = dataIn.readLine();
System.out.print("For how many months is the loan? ");
inputMonths = dataIn.readLine();
System.out.print("What is the decimal interest rate? ");
inputAnnualInterest = dataIn.readLine();
//Conversions
price = Integer.parseInt(inputPrice);
downpayment = Integer.parseInt(inputDownPayment);
tradeIn = Integer.parseInt(inputTradeIn);
months = Integer.parseInt(inputMonths);
annualInterest = Double.parseDouble(inputAnnualInterest);
interest =(int)annualInterest/12;
loanAmt = price-downpayment-tradeIn;
//payment = loanAmt*interest/a-(1+interest)
payment=(loanAmt/((1/interest)-(1/(interest*Math.pow(1+interest,-months)))));
//Output
System.out.print("The monthly payment for " + custName + " is $");
System.out.println(payment);
// figures out monthly payment amount!!!
}
}
the problem occurs when attempting to set the payment variable.
i don't understand why it keeps coming up with dividing by 0 error.
You have declared your variables as Int so 1/interest and 1/(interest*Math.pow(1+interest,-months)) will return 0. Change the type of your variables to float or double.
One suggestion to you, is that you should learn to "backwards slice" your code.
This means that when you see that you're getting a DivideByZeroException you should look at your code, and say, "why could this happen?"
In your case, let's look at this:
payment=(loanAmt/((1/interest)-(1/(interest*Math.pow(1+interest,-months)))));
So, now, Math.pow will never return anything zero (as it's a power), so it must be the case that interestis zero. Let's find out why:
interest =(int)annualInterest/12;
So now, integer division in Java truncates. This means that if you have .5 it will be cut off, and turned into zero. (Similarly, 1.3 will be truncated to 0).
So now:
annualInterest = Double.parseDouble(inputAnnualInterest);
This implies that you are passing in something that gets parsed to a value that is less than 12. If it were greater than 12 then you would get something else.
However, you might just be passing in an invalid string, for example, passing in "hello2.0" won't work!
This will be rounding always to 0. So it is trowing exception.
(1/interest)-(1/(interest*Math.pow(1+interest,-months)))));
Use float type instead of int. Learn how they works.
package computeloan;
import java.util.Scanner;
public class ComputeLoan {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print(" Enter Yearly Interest Rate : ");
double annualIntersetRate = input.nextDouble();
double monthlyIntersetRate = annualIntersetRate / 1200;
System.out.print(" Enter Number of years : ");
int numberOfYears = input.nextInt();
// Enter loan amount
System.out.print(" Enter Loan Amount : ");
double loanAmount = input.nextDouble();
double monthlyPayment = loanAmount * monthlyIntersetRate /(1-1/Math.pow(1+monthlyIntersetRate,numberOfYears*12 ));
double totalPayment = monthlyPayment * numberOfYears * 12;
//Calculate monthlyPaymeent and totalPayment
System.out.println(" The Monthly Payment Is : " +(int)(monthlyPayment*100) /100.0);
System.out.println(" The Total Payment Is : " +(int)(totalPayment*100) /100.0 );
}
}