Question 1 #include using namespace std; int main () { float x, y, area, perimeter; cout << "Length = "; cin >> x; cout << "Width = "; cin >> y; area = x * y; perimeter = (x + y) * 2; cout << "Area = " << area << endl; cout << "Perimeter = " << perimeter << endl; return 0; } Question 2 #include using namespace std; int main () { int x; cout << "Enter an integer: "; cin >> x; cout << "The next three consecutive integers are " << x+1 << "," << x+2 << "," << x+3; return 0; } Question 3 #include using namespace std; int main () { char c; cout << "Enter a character: "; cin >> c; cout << "The ASCII code of " << c << " is " << int(c) << endl; return 0; } Question 4 #include using namespace std; int main () { char c; cout << "Enter a lowercase character: "; cin >> c; cout << "The coresponding uppercase letter is " << (char)(c-32) << endl; return 0; } Question 5 #include using namespace std; int main () { int height, feet, inch; cout << "Enter your height in inches: "; cin >> height; feet = height / 12; inch = height % 12; cout << "You are " << feet << " feet and " << inch << " inches tall" << endl; return 0; } Question 6 #include using namespace std; int main() { int amount, ten, five, one; cout << "How much do you need to pay? "; cin >> amount; ten = amount / 10; five = (amount % 10) / 5; one = (amount % 10) % 5; cout << "Number of $10 coins: " << ten << endl; cout << "Number of $5 coins: " << five << endl; cout << "Number of $1 coins: " << one << endl; return 0; } Question 7a #include using namespace std; int main() { int m, month; cout << "Enter the month in number format: "; cin >> m; cout << "The month in text format: "; if (m == 1) cout << "January" << endl; else if (m == 2) cout << "February" << endl; else if (m == 3) cout << "March" << endl; else if (m == 4) cout << "April" << endl; else if (m == 5) cout << "May" << endl; else if (m == 6) cout << "June" << endl; else if (m == 7) cout << "July" << endl; else if (m == 8) cout << "August" << endl; else if (m == 9) cout << "September" << endl; else if (m == 10) cout << "October" << endl; else if (m == 11) cout << "November" << endl; else if (m == 12) cout << "December" << endl; else cout << "Invalid Input" << endl; return 0; } Question 7b #include using namespace std; int main() { int m, month; cout << "Enter the month in number format: "; cin >> m; cout << "The month in text format: "; switch (m) { case 1: cout << "January" << endl; break; case 2: cout << "February" << endl; break; case 3: cout << "March" << endl; break; case 4: cout << "April" << endl; break; case 5: cout << "May" << endl; break; case 6: cout << "June" << endl; break; case 7: cout << "July" << endl; break; case 8: cout << "August" << endl; break; case 9: cout << "September" << endl; break; case 10: cout << "October" << endl; break; case 11: cout << "November" << endl; break; case 12: cout << "December" << endl; break; default: cout << "Invalid Input" << endl; } return 0; } Question 8 #include using namespace std; int main () { int hour, wage; cout << "Number of working hours = "; cin >> hour; if (hour <= 40) wage = 60 * hour; else if (hour <=65) wage = 60 * 40 + 90 * (hour - 40); else wage = 60 * 40 + 90 * 25 + 120 * (hour - 65); cout << "The wage is equal to " << wage << endl; return 0; } Question 9 #include using namespace std; int main () { int paper1, paper2, total; bool pass; cout << "Paper 1 = "; cin >> paper1; cout << "Paper 2 = "; cin >> paper2; if ((paper1 == -1) && (paper2 == -1)) { total = 0; pass = false; } else if ((paper1 != -1) && (paper2 == -1)) { total = paper1; if (paper1 >= 45) pass = true; else pass = false; } else if ((paper1 == -1) && (paper2 != -1)) { total = paper2; if (paper2 >= 45) pass = true; else pass = false; } else { total = paper1 + paper2; if ((total >= 40) && (paper1 >= 15) && (paper2 >= 15)) pass = true; else pass = false; } cout << "Total Score = " << total << endl; if (pass == true) cout << "You pass the exam." << endl; else cout << "You fail the exam." << endl; return 0; }