repl.it
@ArlanPereira/

Assignment 1

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
32
33
34
35
36
37
38
39
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {
  string item;
  float salesprice;
  float costprice;
  int quantity;
  float total;
  float vat;
  float netprofit;
  string response;
  bool running = true;

  while(running){
    cout << "Enter the name of the item" << endl;
    cin >> item;
    cout << "Enter the sales price" << endl;
    cin >> salesprice;
    cout << "Enter the cost price" << endl;
    cin >> costprice;
    cout << "Enter the quantity sold" << endl;
    cin >> quantity;
    total = quantity * salesprice;
    cout << quantity << " " << item << "s sold at £" << salesprice << " is £" << total << endl;
    vat = (total / 100) * 20;
    cout << "Vat at 20% is £" << vat << endl;
    netprofit = ((salesprice * quantity) - (costprice * quantity)) - vat;
    cout << "Net Profit = £" << netprofit << endl;
    cout << "Would you like to calculate another item? y/n" << endl;
    cin >> response;
    if(response == "n"){
      running = false;
    }
  } 
  cout << "Thanks for using this program. Have a great day. Loggin off. Bubbuy.";
}