Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include #include using namespace std; int main() { int a, b; int oldest = -99;

ID: 3552254 • Letter: #

Question

#include #include


using namespace std;


int main()

{

int a, b; int oldest = -99; //dummy value cout

<< "Enter your age and a friends age. " << endl; cin >> a >> b; //#1 - Write an if statement to determing if your or your friends age is older.


cout << "The oldest age is " << oldest <<< endl; //<- fix this to output oldest age int c, d, e;


cout << "Enter your height in inches and two other heights. " << endl; //#2 using if, else if statements, output the largest height int f;

cout << "Enter a number between 1 and 5 " << endl; //#3 Using a switch statement, output Hi for a user input of 1, By for 2, Sup for 3, Ciao for 4, and Guten Tag for 5


//#4 Print Hello ten times using a while loop


//#5 Print By to the screen 5 times with a do..while loop


//#6 Print Go Bucs to the screen 15 times with a for loop return 0; }

Explanation / Answer

<< "Enter your age and a friends age. " << endl; cin >> a >> b; //#1 - Write an if statement to determing if your or your friends age is older.


if (a<b) {

cout<<"Your friends age is older";

}


else {

cout<<"Your age is older";

}


cout << "Enter your height in inches and two other heights. " << endl; //#2 using if, else if statements, output the largest height int f;



cin>>a>>b>>c;


if(a>b && a>c) {

int x = a * 0.0833333 //Converting inch to feet

cout<<x; //Output of largest heigh in feet

}


else if(b>a && b>c) {

int x = b * 0.0833333 //Converting inch to feet

cout<<x; //Output of largest heigh in feet

}


else if(c>b && c>a) {

int x = c * 0.0833333 //Converting inch to feet

cout<<x; //Output of largest heigh in feet

}


cout << "Enter a number between 1 and 5 " << endl; //#3 Using a switch statement, output Hi for a user input of 1, By for 2, Sup for 3, Ciao for 4, and Guten Tag for 5


int a;

cin>>a;

switch(a)

{

case 1 :

cout << "Hi" << endl;

break;

case 2 :

cout << "By" << endl;

break;

case 3 :

cout << "Sup" << endl;

break;

case 4 :

cout << "Ciao" << endl;

break;

case 5:

cout << "Guten Tag" << endl;

break;


default :

cout << "Invalid " << endl;

}


/#4 Print Hello ten times using a while loop

int x = 0;


while(x<10) {

cout<<"Hello";

x++;

}


//#5 Print By to the screen 5 times with a do..while loop


int x = 0;

do {

cout<<"By";

x++

} while(x<5)


/#6 Print Go Bucs to the screen 15 times with a for loop return 0; }

84