Sunteți pe pagina 1din 7

ASSIGNMENT NO.

USING THE WHILE LOOPING (REPETITION) STRUCTURE


ORDER ROOM

FRISNEDI, NADINE T.

PROF.
GENNESIS JOY G. CEREDON

FEBRUARY 4, 2014

PROBLEM ANALYSIS
The Lab Activity is about designing a program using loops. That program
should simulate an order room of a factory. The programmer is tasked to create a
program that can record items and its price which was ordered by the user. The
program will continue asking the same two questions. When the user is done
encoding the items and prices, he/she can stop the program by inputting 999 when
prompted again with this: Please scan the name of the next item:. The program
will tell the user: Thank you for your order. The results should be in an output file.
The first program ends in that process.
The second program will be using the output file from the previous program.
The program will prompt the user to enter the name of the item and it will search for
that item. It will display the item name and the price. The program will continue
asking the question and display the name and price. If there is an item you have
inputted but not included in the input file, the program will tell the user: The item
was not found.. The second program should end in this way.
The third program is going to use mostly the functions in the second program.
I should read the item name and price. It should also accumulate all the prices in
the input file. It should display each name, and price, total count and total amount
in currency format. The resulting program should be copied also in the code as a
comment.

Algorithm Design
2a-2c.
1. Use the required pre-processor directives such as <fstream> for files.
2. Set variables for all.
3. Declare stream variable for output file.
4. Prompt the user for the name of an item.
5. Prompt the user for the price of the item.
6. For the output file, set the variable needed to be displayed and the separator
of the name and price, #.
7. Use while loop.
8. Set condition of loop, that when 999 is entered for the value of the variable
item which is the name of the item to be ordered, the program will stop and
display a default message. (if statement)
9. If not, the program will continue asking the user to enter the name and price
of items. (else)
10.

Close the file.

11.

Open the output file to check if the program works effectively.

3a-3c
1. Use the required pre-processor directives such as <fstream> for files.
2. Set variables for all.
3. Declare stream variable for input file.
4. Open input file.
5. Prompt the user for the name of an item.
6. Use while loop.
7. Checking if the item name exists or not

8. If not, tells the user "Unable to open file


9. else asks the user to enter the item name to search
10. start of loop while search is not equal to 999
11. Entering the search.
12. If search is found.
13. Use the function getline to look for the search key inside the invoice1.txt (
the input file
14. If found, get the price of the searched item.
15. Close the file.
4a-4c.
1. Use the required pre-processor directives such as <fstream> for files.
2. Set variables for all.
3. Declare stream variable for input file.
4. Open input file.
5. Use while loop.
6. Read the contents of the input file.
7. Use the function getline to look for the search key inside the invoice1.txt ( the
input file
8. If found, get the price of the searched item.
9. Continue this process.
10. List the accumulated orders.
11. Add the total number of items.
12. Add the total amount.
13. Display the names, prices, total number of items, and total amount in
currency form.
14. Close the file.

Screenshot of the working program


Scan1

S-ar putea să vă placă și