/** Project—CD Store

advertisement
/** Project—CD Store
* A program that will determine the cost of buying
* several used music CDs. The program is able to input the
* number of CD color tabs and then show the total price
* including a 7% sales tax.
*
* Red- $20.00
* Blue- $15.00
* Yellow- $10.00
* White- $5.00
*/
import java.io.*;
import java.util.*;
public class CdPrice
{
public static void main(String args[])
{
//Declare Variables
Scanner kbReader = new Scanner(System.in);
int rTab; int bTab; int yTab; int wTab; // Color of tabs
int totalCds;
double totalPrice = 0.0;
double tax;
double finalPrice;
//Print Menu
System.out.println(""); //Spacer
System.out.println("**** Welcome to Used CDs For Less ****");
System.out.println(""); //Spacer
System.out.println("The colors are:");
System.out.println("Red -\t\t$20.00");
System.out.println("Blue -\t\t$15.00");
System.out.println("Yellow -\t$10.00");
System.out.println("White - \t$5.00");
System.out.println("______________________"); //Separator
System.out.println(""); //Spacer
//Instructions
System.out.println("Please input the number each CD color tabs:");
System.out.println(""); //Spacer
//Red tabs
System.out.print("Enter number of Red Tabs =\t");
rTab = kbReader.nextInt();
totalPrice += (rTab*20.0);
//Blue tabs
System.out.print("Enter number of Blue Tabs =\t");
bTab = kbReader.nextInt();
totalPrice += (bTab*15.0);
//Yellow tabs
System.out.print("Enter number of Yellow Tabs =\t");
yTab = kbReader.nextInt();
totalPrice += (yTab*10.0);
//White tabs
System.out.print("Enter number of White Tabs =\t");
wTab = kbReader.nextInt();
totalPrice += (wTab*5.0);
System.out.print(""); //Spacer
//Find tax
tax = totalPrice*.07;
//Add tax to total price to find final price
finalPrice = totalPrice + tax;
//Separator of number of each kind of cd from total numbers of cds
System.out.println(""); //Spacer
System.out.println("\t\t\t\t--");
System.out.println(""); //Spacer
//Find And print total number of CDS
totalCds = rTab + bTab + yTab + wTab;
System.out.println("\tTotal number of CDs =\t" + totalCds);
System.out.println(""); //Spacer
//Print final Price
System.out.println("\tYour Total Including GA Sales Tax is: $" + finalPrice);
System.out.println(""); //Spacer
//Say Thank You
System.out.print("\tThank You!");
}
}
Download