116 HW2
116 HW2
1 2
2 3
3 2
4 3
1
Input /Output Samples:
Problem 2
Write a C++ program to prompt the user to enter an integer number greater than 1, then find the last
prime number that occurs before the entered number.
2
Chapter 3: Input/Output
Problem 3 Temperature
Write a C++ program that reads daily temperature data for a Sample output:
month and calculates the average temperature for each day
and the overall temperature of the month. The program should
read the data for the entire month from a file named
temperatures.txt (given). Assume the month has 30 days. The
input file contains one line for each day, where each line has 4
temperature readings (in degrees Celsius) for that day,
separated by spaces. Adjust decimal placed as per the below
sample output.
temeratures.txt content:
You are given a text file named accounts.txt containing accounts.txt content:
information about several customers' bank accounts. Each line
in the file represents a single customer's account details with
the following format:
AccountID FirstName LastName InitialBalance
Write a C++ program that reads this file and then performs a
series of operations on each account based on another input transaction.txt content:
file named transactions.txt. This file contains a series of
transactions to be applied to the accounts, formatted as
follows:
AccountID TransactionType Amount
Where TransactionType is either D for deposit or W for
withdrawal. See sample content of transactions.txt file.
After processing all transactions, the program should generate report.txt content:
an output report named report.txt that lists the final balance of
each account, including the account ID, the customer's name,
and the final balance, formatted like the original input. Check
sample output. All input files are given.