Instruction: Using conditional statements, looping and functions, write an INTERACTIVE PROGRAM on BODY SYSTEMS. Each student must have two questions about the BODY SYSTEM.
Sample Output
Select Body System:
Enter Number of Body System: 1
Output:
Questions For Respiratory System:
Enter Number of Question: 1
Output:
Question 1:
Sample Question 1
Answer 1:
Sample Answer 1
Write a program that asks the user to enter a distance in meters. The program will then present the following menu of selections:
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Here is an example session with the program, using console input. The user’s input is shown in bold.
Enter a distance in meters: 500 [enter]
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 1 [enter]
500 meters is 0.5 kilometers.
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 3 [enter]
500 meters is 1640.5 feet.
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 4 [enter]
Bye!
A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges P120.00 per hour for labor. Write a program that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. The program should have functions that return the following data:
· The number of gallons of paint required
· The hours of labor required
· The cost of the paint
· The labor charges
· The total cost of the paint job
Then it should display the data on the screen.
A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a C++ program using a function that takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the function in a complete C++ program.
. Rewrite the following expressions using an if...else statement. (Assume that all variables are declared properly.)
a. (x < 5) ? y = 10 : y = 20;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (booksBought >= 3) ? discount = 0.15 : discount = 0.0;
Which of the following apply to the while loop only? To the do...while loop only? To both?
a. It is considered a conditional loop.
b. The body of the loop executes at least once.
c. The logical expression controlling the loop is evaluated before the loop is
entered.
d. The body of the loop may not execute at all.
Rewrite the following expressions using an if...else statement. (Assume that all variables are declared properly.)
a. (x < 5) ? y = 10 : y = 20;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (booksBought >= 3) ? discount = 0.15 : discount = 0.0;
2. Suppose that x, y, and z are int variables, and x = 10, y = 15, and z = 20. Determine
whether the following expressions evaluate to true or false:
a. !(x > 10)
b. x <= 5 || y < 15
c. (x != 5) && (y != z)
d. x >= z || (x + y >= z)
e. (x <= y - 2) && (y >= z) || (z - 2 != 20)
3. Rewrite the following expressions using an if...else statement. (Assume that all variables
are declared properly.)
a. (x < 5) ? y = 10 : y = 20;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (booksBought >= 3) ? discount = 0.15 : discount = 0.0;
Create class called match; the class must have the following data members and methods:
Data Members:
•This class has two data members named HomeTeam and VisitorTeam which are of type Team, they will store that two teams that will play the Match.
Methods:
•This class doesn’t have a default constructor, it only has one constructor which receives two Team object that will be assigned to HomeTeam and VisitorTeam.
•setTeams(),which receives two Team object that will be assigned to HomeTeam and VisitorTeam.
•playMatch(), simulates match play by calling the scoreGoals methods of each team.
•getPlayGound(), returns the ground of play which is the HomeGound of the HomeTeam.
•isDrawMatch(), will return true if the Match is a draw and false if there is a winner. The match is a draw if the goals of the teams are equal. •getWinner(), returns the team which won the match, a team wins if its goals is higher than the goals of the other team.
Create a class called Match that will have team the class must have the following data members and methods:
Data Members:
• This class has two data members named HomeTeam and VisitorTeam which are of type Team, they will store that two teams that will play the Match.
Methods:
• This class doesn’t have a default constructor, it only has one constructor which receives two Team object that will be assigned to HomeTeam and VisitorTeam.
• setTeams(),which receives two Team object that will be assigned to HomeTeam and VisitorTeam.
• playMatch(), simulates match play by calling the scoreGoals methods of each team.
• getPlayGound(), returns the ground of play which is the HomeGound of the HomeTeam.
• isDrawMatch(), will return true if the Match is a draw and false if there is a winner. The match is a draw if the goals of the teams are equal.
• getWinner(), returns the team which won the match, a team wins if its goals is higher than the goals of the other team.