-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfor-while.cpp
More file actions
39 lines (33 loc) · 1.04 KB
/
for-while.cpp
File metadata and controls
39 lines (33 loc) · 1.04 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
#include <iostream>
using namespace std;
int main()
{
char choice;
int a = 0;
int counter = 0;
int counter2 = 0;
cout << "Hello Welcome to Ryan's Farms!" << "\n" << "We have a great selection for you today! \n";
while (a <= 6){
cout << "Would you like to try to pick an apple";
for (counter = 0 ; counter < counter2 ; counter++) cout << " again";
cout << "?" << "\n";
cin >> choice;
if (choice == 'y') { a++; counter2 = 1; cout << "Great you have " << a << " apples! \n";
}
else if (choice == 'n'){cout <<"Nice Call saving the tree \n"; break;}
}
if (a >= 7){
cout << "You are really greaty taking " << a << " apples. \n";
cout << "*Takes 6 apples away* \n";
cout << "I leave you with 1 apple because I am Nice \n";
a = -1;
}
if (a <= 6){
cout << "Thanks for visiting the farm! \n";
}
if (a = -1){
a = 1;
}
cout << "You are leaving with " << a << " apples. \n";
return 0;
}