CPP
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
// ex. by Scott D.
/* https://www.sololearn.com/Profile/27308012/?ref=app
*/
#include <iostream>
using namespace std;
int main() {
int unit = 5; // unit price
float tax = .07;
float disc = .1; // discount
int sales; // units purchased
cin >> sales;
// unit price with discount
float unitDisc = (unit - unit * disc);
// total of discounted units sold + tax
float salesDisc = sales * unitDisc + sales * unitDisc * tax;
// convert >3 decimal points to only 2
float mult = (salesDisc + .005) * 100;
int round = mult ;
float out = round ;
if (sales == 1)
{
cout << unit + unit * tax;
}
else cout << out/100 ;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run