Click here to Skip to main content
15,885,711 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Its almost valentines day and the prices of roses need to be adjusted. The type of roses and the prices need to be read from the file "Stock.dat". Once the information has been read the prices need to be increased by R10. The type of roses and their adjusted prices should be recorded in the file "Valentines.dat".

What I have tried:

Start
Declaration 
Num = prices
Num =roses
Output "types roses and prices from stock.dat"
Input price+R10
Input "Record types of roses and  prices in a fileValentines.dat"
Output "types of roses and prices" 
Stop
Posted
Updated 27-Nov-20 5:56am
v2
Comments
DerekT-P 27-Nov-20 7:43am    
You need to speak with your tutor, as you've illustrated no understanding of pseudocode, nor of the problem at hand. We are not here to do your assignments, and if we did, it would not help you since at your level of understanding you'd gain nothing from it. Go back and read your programming books from the very start, and seek help from your tutor. Sorry, but there wasn't really a "nice" way to say this!
PIEBALDconsult 27-Nov-20 9:47am    
Read the input
Perform calculations
Write output
Done

Your attempt is a start.
Now you should make another effort to better detail what you code would do (i.e. open the file, then reading the prices in loop that ends upon receiving 'end of file', etc...)
e.g.
inputFile = open file "Stock.dat"
while is not end of file inputFile do
  typeOfRose = read type of rose from inputFile
  currentPrice = read current price from inputFile  
  ...
...
 
Share this answer
 
0) create a collection containing key-value pairs of type string, double.

1) open a file named Stock.dat

2) based on your knowledge of the file-structure:

a. parse the file, adding key-value pairs of type string, double to the collection

3) enumerate the collection and either:

a. modify the price by some factor

b. or, write the modified price value and name into another collection

4) save the collection to a file named Valentines.dat
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900