-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask3.cpp
More file actions
45 lines (39 loc) · 1.11 KB
/
task3.cpp
File metadata and controls
45 lines (39 loc) · 1.11 KB
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
#include <iostream>
using namespace std;
int main3()
{
int NoChoc, WeiChoc;
double TotWei;
char convert;
cout << "Enter the number of chocolates being sold ";
cin >> NoChoc;
cout << "Enter weight of one chocolate in ounces ";
cin >> WeiChoc;
cout << "Enter the choice for weighing " << endl;
cout << " Enter O to calculate in ounces " << endl << "P for pounds" << endl << "G for grams " << endl << "K for kilograms " << endl;
cout << "Enter your choice here ";
cin >> convert;
if (convert == 'o' || convert == 'O')
{
TotWei = NoChoc * WeiChoc;
cout << "Weight in Ounces is " << TotWei << endl;
}
else if (convert == 'p' || convert == 'P')
{
TotWei = NoChoc * WeiChoc / 16;
cout << "Weight in Pounds is " << TotWei << endl;
}
else if (convert == 'g' || convert == 'G')
{
TotWei = NoChoc * WeiChoc * 28.349;
cout << "Weight in Grams is " << TotWei << endl;
}
else if (convert == 'k' || convert == 'K')
{
TotWei = NoChoc * WeiChoc * 28.349 / 1000;
cout << "Weight in Kilograms is " << TotWei << endl;
}
else
cout << "Please enter a valid option " << endl;
return 0;
}