3
//Project P1 DAVIDSON, COURTNEY #include <iostream> using namespace std; int main () {  char item1 [20]; int qnty1; float cost1, total1; cout << "What item did you buy?\n"; cin >> item1; cout << "What did this item cost?\n"; cin >> cost1; cout << "What quantity did you buy?\n"; cin >> qnty1; //Calculate money spent on Item 1. total1 = cost1 * qnty1;  //Display money spent on Item 1. cout << "Money spent on item is $" << total1 << endl; //Proceed to Item 2.  char item2 [20]; int qnty2; float cost2, total2;  cout << "What item did you buy?\n"; cin >> item2; cout << "What did this item cost?\n"; cin >> cost2; cout << "What quantity did you buy?\n"; cin >> qnty2;  //Calculate money spent on Item 2. total2 = cost2 * qnty2; //Display money spent on Item 2. cout << "Money spent on item is $" << total2 << endl;  //Proceed to Item 3.  char item3 [20]; int qnty3; float cost3, total3; cout << "What item did you buy?\n"; cin >> item3; cout << "What did this item cost?\n"; cin >> cost3; cout << "What quantity did you buy?\n"; cin >> qnty3;  //Calculate money spent on Item 3. total3 = cost3 * qnty3;  //Display money spent on Item 3. cout << "Money spent on item is $" << total3 << endl;

P1 -- CODE.txt

  • Upload
    dffdf

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

7/27/2019 P1 -- CODE.txt

http://slidepdf.com/reader/full/p1-codetxt 1/3

//Project P1 DAVIDSON, COURTNEY#include <iostream>using namespace std;int main (){ char item1 [20];int qnty1;float cost1, total1;

cout << "What item did you buy?\n";cin >> item1;cout << "What did this item cost?\n";cin >> cost1;cout << "What quantity did you buy?\n";cin >> qnty1;

//Calculate money spent on Item 1.total1 = cost1 * qnty1; //Display money spent on Item 1.cout << "Money spent on item is $" << total1 << endl;

//Proceed to Item 2.

 char item2 [20];int qnty2;float cost2, total2; cout << "What item did you buy?\n";cin >> item2;cout << "What did this item cost?\n";cin >> cost2;cout << "What quantity did you buy?\n";cin >> qnty2; //Calculate money spent on Item 2.

total2 = cost2 * qnty2;

//Display money spent on Item 2.cout << "Money spent on item is $" << total2 << endl; //Proceed to Item 3. char item3 [20];int qnty3;float cost3, total3;

cout << "What item did you buy?\n";cin >> item3;

cout << "What did this item cost?\n";cin >> cost3;cout << "What quantity did you buy?\n";cin >> qnty3; //Calculate money spent on Item 3.total3 = cost3 * qnty3; //Display money spent on Item 3.cout << "Money spent on item is $" << total3 << endl;

7/27/2019 P1 -- CODE.txt

http://slidepdf.com/reader/full/p1-codetxt 2/3

 //Proceed to Item 4.

char item4 [20];int qnty4;float cost4, total4;

cout << "What item did you buy?\n";cin >> item4;cout << "What did this item cost?\n";cin >> cost4;cout << "What quantity did you buy?\n";cin >> qnty4;

//Calculate money spent on Item 4.total4 = cost4 * qnty4;

//Display money spent on Item 4.cout << "Money spent on item is $" << total4 << endl; //Proceed to Item 5.

char item5 [20];int qnty5;

float cost5, total5; cout << "What item did you buy?\n";cin >> item5;cout << "What did this item cost?\n";cin >> cost5;cout << "What quantity did you buy?\n";cin >> qnty5; //Calculate money spent on Item 5.total5 = cost5 * qnty5;

//Display money spent on Item 5.

cout << "Money spent on item is $" << total5 << endl; float subtotal, salestaxp, percent, salestax, total, payment, change; // Calculate Subtotal.subtotal = total1 + total2 + total3 + total4 + total5; //Display Subtotal.cout << "Your subtotal is $" <<subtotal<< endl; cout << "What is the sales tax in your area?\n";cin >> salestaxp; 

// Calculate salestax percentage.percent = salestaxp / 100;

// Calculate salestax.salestax = subtotal * percent;

// Display salestax.cout << "Salestax is $" << salestax << endl;

// Calculate total spent.

7/27/2019 P1 -- CODE.txt

http://slidepdf.com/reader/full/p1-codetxt 3/3

total = subtotal + salestax;

//Display the total spent.cout << "You spent $" << total << endl;

cout <<"What did you pay the cashier?\n";cin >> payment;

//Calculate change.change = payment - total;

//Display change received.cout <<"The change you received is $" << change << endl;

return 0;}