-
Notifications
You must be signed in to change notification settings - Fork 0
/
4_7.cpp
48 lines (40 loc) · 982 Bytes
/
4_7.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
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
using namespace std;
struct Pizza
{
string brand;
float diameter;
float weight;
};
int main()
{
Pizza pizza;
cout << "Please enter the brand of the pizza: ";
while(!getline(cin, pizza.brand))
{
cout << "Error! Please re-enter the brand of the pizza: ";
cin.clear();
cin.sync();
}
cout << "Please enter the diameter of the pizza: ";
while(!(cin >> pizza.diameter))
{
cout << "Error! Please re-enter the diameter of the pizza: ";
cin.clear();
cin.sync();
}
cout << "Please enter the weight of the pizza: ";
while(!(cin >> pizza.diameter))
{
cout << "Error! Please re-enter the weight of the pizza: ";
cin.clear();
cin.sync();
}
cout << "Here's the information of the pizza: " << endl;
cout << "Brand: " << pizza.brand << endl;
cout << "Diameter: " << pizza.diameter << endl;
cout << "Weight: " << pizza.weight << endl;
// system("pause");
return 0;
}