Question: 1. Create a C++ program called lab1_1.cpp that reads three numbers from a user. Then it calls a function named find_max() , which takes three

1. Create a C++ program called lab1_1.cpp that reads three numbers from a user. Then it calls a function named find_max(), which takes three integers are arguments, finds the largest of the three numbers, and then returns the largest number. This result is finally printed onto the screen.

Here is your function prototype:

int find_max(int x, int y, int z);

Here is your main function (note you must use this main, you aren't allowed to modify it):

int main() { int num1, num2, num3, largest; cout << "Please enter three numbers: "; cin >> num1 >> num2 >> num3; //write the statement that calls find_max() and stores //the value returned in largest cout << "The largest number is " << largest << ". "; return 0; }

Now finish the program!

A sample run of your program might look like this.

Please enter three numbers: 3 5 6 The largest number is 6.

This is another sample run of your program:

Please enter three numbers: 3 5 5 The largest number is 5.

This is another sample run of your program:

Please enter three numbers: 3 3 3 The largest number is 3.

2. Create a C++ program called lab1_2.cpp that simulates a vending machine. In this program, you have to use two functions to achieve this task. A sample run of your program might look like this.

Welcome to the Hartnell Vending Machine Insert money: $10 Today's Menu A. Regular coffee: ($3) B. Regular decaf: ($2) C. Combo: ($5) D. Soda: ($1) Select your choice: A You selected regular coffee. Your change is: $7.00 Have a nice day!

This is another sample run of your program:

Welcome to the Hartnell Vending Machine Insert money: $1 Today's Menu A. Regular coffee: ($3) B. Regular decaf: ($2) C. Combo: ($5) D. Soda: ($1) Select your choice: B You selected decaf coffee. Sorry! You dont have enough money. Your change is: $1.00 Have a nice day!

This is another sample run of your program:

Welcome to the Hartnell Vending Machine Insert money: $10 Today's Menu A. Regular coffee: ($3) B. Regular decaf: ($2) C. Combo: ($5) D. Soda: ($1) Select your choice: E Sorry! Thats an invalid choice. Your change is: $10.00 Have a nice day!

You will start by to using the following main, but finish it by defining the missing code

/* * Title: lab1_2.cpp * Description: * Author: * Date: */ #include  #include  using namespace std; // Declare the two functions here int main() { // declarations double money; char option; // formatting cout.setf(ios::showpoint); cout.setf(ios::fixed); cout.precision(2); // prompt cout << "Welcome to the Hartnell Vending Machine "; cout << "Insert money: $"; cin >> money; if(money < 0) { cout << "Sorry, you're out of luck. "; exit(1); } menu(); cout << "Select your choice: "; cin >> option; money = pay(option, money); cout << "Your change is: $" << money << endl; cout << "Have a nice day! "; return 0; } // Develop the functions themselves here.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!