Lab 1
Lab 1
Lab 1
Total marks: 10
Problem 1:
Filename: prob1_yourstudentid.cpp
Requirement(s):
o Write an application to display your name using cout then use endl to skip a line after
the display.
Problem 2:
Problem 3:
Filename: prob3_yourstudentid.cpp
There are three seating categories at a stadium. For a softball game, Class A seats cost $15, Class
B seats cost $12, and Class C seats cost $9. Write a program that asks how many tickets for each
class of seats were sold, then displays the amount of income generated from ticket sales.
Format your dollar amount in fixed-point notation, with two decimal places of precision, and be
sure the decimal point is always displayed.
o cout, cin, int, double, arithmetic, fixed, setprecision, showpoint
Problem 4:
Filename: prob4_yourstudentid.cpp
Write a program that asks the user for the number of males and the number of females
registered in a class. The program should display the percentage of males and females in the
class.
Hint: Suppose there are 8 males and 12 females in a class. There are 20 students in the class.
The percentage of males can be calculated as 8 ÷ 20 = 0.4, or 40 percent. The percentage of
females can be calculated as 12 ÷ 20 = 0.6, or 60 percent.
o cout, cin, int, double, arithmetic, setw, setprecision
INFO 1112
Lab 1
Problem 5:
Filename: prob5_yourstudentid.cpp
Write a program that will convert U.S. dollar amounts to Japanese yen and to euros, storing the
conversion factors in the constants YEN_PER_DOLLAR and EUROS_PER_DOLLAR. To get the
most up-to-date exchange rates, search the Internet using the term “currency exchange rate”.
o 1 Dollar = 131.66 Yen
o 1 Dollar = 0.93 Euros
Format your currency amounts in fixed-point notation, with two decimal places of precision, and
be sure the decimal point is always displayed.
o Const, double, cout, cin, arithmetic, fixed, setprecision, showpoint
Problem 6:
Filename: prob6_yourstudentid.cpp
Write a program that can be used as a math tutor for a young student. The program should
display two random numbers to be added, such as
INFO 1112
Lab 1
Problem 7: [4 marks]
Filename: prob7_yourstudentid.cpp
Write a program that plays a word game with the user. The program should ask the user to
enter the following:
o His or her name
o His or her age
o The name of a city
o The name of a college
o A profession
o A type of animal
o A pet’s name
After the user has entered these items, the program should display the following story, inserting
the user’s input into the appropriate locations: