Lab 7 Inlab Assignment

Lab 7 Inlab Assignment

Lab 7 Inlab assignment

Problem 1: File I/O

Modify the following program to get input from a file(inData.txt) and save the output to a file(outData.txt). Create inData.txt and outData.txt before you run your program, make outData.txt blank and put the following information to inData.txt:

John 15

#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
int ID;
cout < "Enter your name ";
cin > name;
cout < "Enter your ID number ";
cin > ID;
cout < "Hello " < name < " or should I say " < ID < endl;
return 0;
}

Problem 2: This lab assignment is from Prof. Zelikovitz.

Be sure to include comments at the beginning of the program with your name, date etc, and comments throughout the program to explain your code. Use const whenever appropriate.

1) Write a program to compute and print the cost of airline tickets from Boston to New York.

Your program prompts the user to input a ticket price.

Your program prompts the user to input the number of tickets to be bought.

Due to a membership in travel clubs you will receive a 13% discount.

There is 8.75% tax on the price of the tickets plus a airport charge of $15.

Your program should print out the total amount due in the following format (you may use spaces or the tab for the white space, which does not have to be a specific number of spaces), with the following input.

# of tickets: 5 @ $178.00

subtotal:<subtotal here>

amount of discount:<amount of discount>

total without tax: <total without tax>

tax:<tax>

airport charge:$15

total due: <total due>

2) Run your program on two more sets of input:

6 tickets at $150 each

10 tickets at $105.60 each

Print and submit all source code and 3 printouts of output.

3) Instead of the output above, have your output formatted so that when it is printed out it looks like a receipt from a travel agency. For example:

# of tickets:5 @ $178.00

subtotal:<subtotal here>

amount of discount:<amount of discount>

total without tax: <total without tax>

tax:<tax>

airport charge:$15

total due: <total due>

4) Instead of standard input/output above, have your program to read the input from the input file named as inData.txt and write the output into a output file named as outData.txt.

The file inData.txt has the following contents:

178.005