PLEASE HELP WITH JAVA Youve been hired by Finders Keepers to

PLEASE HELP WITH JAVA!

You\'ve been hired by Finders Keepers to write a Java console application that determines the amount and type of change to return to a customer for a given sale. Use a validation loop to prompt and get from the user the sale amount in the range $1-8. Then use a validation loop to prompt and get from the user the amount tendered by the customer to insure it is at least the sale amount. Calculate the number of fives, ones, quarters, dimes, nickels, and pennies that should be returned to the customer.
Format the following output in two columns with the first column containing a label and the second column containing the result:
The two inputs.
The change amount.
The number of:
ü Fives
ü Ones
ü Quarters
ü Dimes
ü Nickels
ü Pennies
Format any dollar values to two decimal places. Continue to prompt the user for sales until they enter sale amount -22. Use this data for the last three inputs:
Sale amount($)Amount tendered($)
1.752
2.475.50
7.1110
PLEASE HELP WITH JAVA!

You\'ve been hired by Finders Keepers to write a Java console application that determines the amount and type of change to return to a customer for a given sale. Use a validation loop to prompt and get from the user the sale amount in the range $1-8. Then use a validation loop to prompt and get from the user the amount tendered by the customer to insure it is at least the sale amount. Calculate the number of fives, ones, quarters, dimes, nickels, and pennies that should be returned to the customer.
Format the following output in two columns with the first column containing a label and the second column containing the result:
The two inputs.
The change amount.
The number of:
ü Fives
ü Ones
ü Quarters
ü Dimes
ü Nickels
ü Pennies
Format any dollar values to two decimal places. Continue to prompt the user for sales until they enter sale amount -22. Use this data for the last three inputs:
Sale amount($)Amount tendered($)
1.752
2.475.50
7.1110
PLEASE HELP WITH JAVA!

You\'ve been hired by Finders Keepers to write a Java console application that determines the amount and type of change to return to a customer for a given sale. Use a validation loop to prompt and get from the user the sale amount in the range $1-8. Then use a validation loop to prompt and get from the user the amount tendered by the customer to insure it is at least the sale amount. Calculate the number of fives, ones, quarters, dimes, nickels, and pennies that should be returned to the customer.
Format the following output in two columns with the first column containing a label and the second column containing the result:
The two inputs.
The change amount.
The number of:
ü Fives
ü Ones
ü Quarters
ü Dimes
ü Nickels
ü Pennies
Format any dollar values to two decimal places. Continue to prompt the user for sales until they enter sale amount -22. Use this data for the last three inputs:
Sale amount($)Amount tendered($)
1.752
2.475.50
7.1110

Solution

import java.text.DecimalFormat; //import to get 2 places of decimal
import java.util.Scanner; //to get input
public class Change{
    public static void main(String[] args) {
        //declaring variable
        double saleAmount, amountTendered, changeAmount;
        int fives=0, ones=0, quarters=0, dimes=0, nickels=0, pennies=0;

        System.out.println(\"Enter the sale amount: \");
        Scanner sc = new Scanner(System.in);
        saleAmount = sc.nextFloat();
        while(saleAmount>8 || saleAmount<1){
            System.out.println(\"Please enter a value between 1 and 8.\");
            saleAmount = sc.nextFloat();
        }
        System.out.println(\"Enter the tendered amount: \");
        amountTendered = sc.nextFloat();
        while(amountTendered<saleAmount){
            System.out.println(\"Please enter tendered amount greater than sale amount.\");
            amountTendered = sc.nextFloat();
        }

        DecimalFormat df = new DecimalFormat(\"#.##\");
        saleAmount = Double.valueOf(df.format(saleAmount));
        amountTendered = Double.valueOf(df.format(amountTendered));
        changeAmount = amountTendered - saleAmount;

        //run till the change amount is 0

        while(changeAmount>0){
            if(changeAmount>5){
                fives ++;
                changeAmount -= 5;
            }
            else if(changeAmount>1){
                ones ++;
                changeAmount -= 1;
            }
            else if(changeAmount>0.25){
                quarters ++;
                changeAmount -= 0.25;
            }
            else if(changeAmount>0.1){
                dimes++;
                changeAmount -= 0.1;
            }
            else if(changeAmount>0.05){
                nickels ++;
                changeAmount -= 0.05;
            }
            else{
                pennies ++;
                changeAmount -= 0.01;
            }
        }

        System.out.println(\"Sale Amount: \"+saleAmount);
        System.out.println(\"Tendered Amount: \"+amountTendered);
        System.out.println(\"Change Amount: \"+(amountTendered - saleAmount));
        System.out.println(\"Number of Fives: \"+fives);
        System.out.println(\"Number of ones: \"+ones);
        System.out.println(\"Number of quarters: \"+quarters);
        System.out.println(\"Number of dimes: \"+dimes);
        System.out.println(\"Number of nickels: \"+nickels);
        System.out.println(\"Number of pennies: \"+pennies);

    }
}

 PLEASE HELP WITH JAVA! You\'ve been hired by Finders Keepers to write a Java console application that determines the amount and type of change to return to a c
 PLEASE HELP WITH JAVA! You\'ve been hired by Finders Keepers to write a Java console application that determines the amount and type of change to return to a c
 PLEASE HELP WITH JAVA! You\'ve been hired by Finders Keepers to write a Java console application that determines the amount and type of change to return to a c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site