Help with building cash register for homework

So i am still very new at this, i am basically learning as i go. So my home work is to Write a program that acts as a self-checkout register at a store and lets the user buy 2 items.
The program will prompt the user and read in:
- the name of item 1, such as mechanical pencil.
- the price of item 1 and number of items 1, such as: 2 2.50
- the name of item 2, such as binder
- the price of item 2 and the number of items 2, such as: 3 7.25
Read both the price and the number in one C++ statement
Then the program calculates the total cost of the items, including the sales tax of 8.675%.
The tax should be defined as a constant in the program, and not used as a literal.
Last, the program prints the receipt on screen. The output should be in column format,
and the prices are with 2 digits after the decimal point. You can assume the item names
will not be more than 20 characters wide.

Can any one please help me and point me in the right direction

THank u!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;

const double TAX_RATE=0.08675;

int main()
{

string item1;
string item2;
char sale_type;
int number;
int number2;
double price;
double price2;
double subtotal;
double total;
double tax;

cout << "Choose from the following items below:" <<endl << endl;
cout << "Mechanical_pencil" <<endl <<endl;
cout << "Binder" <<endl <<endl;

cout << "item1 purchased:";
cin >> item1;
cout << "Enter price $:";
cin >> price;
cout << "enter quanity:";
cin >> number;

cout << "item2 Purchased:";
cin >> item2;
cout << "enter price2 $:";
cin >> price2;
cout << "enter quanity:";
cin >> number2;

subtotal = price * number + price * number;
tax = subtotal * TAX_RATE;
total = price * number + price2 * number2 + tax;

cout << "item1 : " << setw(8) << item1 << endl;
cout << "item2 : " << setw(8) << item2 << endl;
cout << "total: " << setw(8) << total << endl;

    return 0;

Last edited on
A few questions...

1. When is this due?

2. What have you learned so far, and if something you haven't learned yet is included in the code could that be caught and punished?

3. Either I or you are misinterpreting the question. Is it asking the user to enter the name of the item they want, or are you supposed to pre-define that?

Let me know if it's just me who sees it that way.
Last edited on
It looks more less ok. But you're not "reading the price and the number in one C++ statement" as requested.

Andy
Topic archived. No new replies allowed.