repl.it
@ArlanPereira/

Price Calculations

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
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
#include <iostream>
using namespace std;

int main() {
  //variables
  string item;
  float price;
  int quantity;
  float total;
  float vat;
  string response;
  bool running = true;

  while(running){
    cout << "Enter the item" << endl;
    cin >> item;
    cout << "Enter the price" << endl;
    cin >> price;
    cout << "Enter the quantity" << endl;
    cin >> quantity;
    total = quantity * price;
    cout << quantity << " " << item << "s at £" << price << " is £" << total << endl;
    vat = (price / 100) * 20;
    cout << "Vat at 20% is £" << vat << endl;
    cout << "Calculate another item? y/n" << endl;
    cin >> response;
    if(response == "n"){
      running = false;
    }
  } 
}