Professional Documents
Culture Documents
Fall 2021-22
Lab Guidelines
1. You must put all your work into a folder named PreLab04_YourRollNo (e.g,
PreLab04_22100063), compress it into a “zip” file and submit the zip file on LMS
(Assignment -> PreLab04) before Monday, 27th Sept 10:55 AM. No late
submissions or email submissions will be accepted.
2. Communicating with each other is NOT permitted. Searching for answers or help on
the internet is not permitted. All help material provided in the Lab Manual is allowed.
If you have a question, ask the TAs on Slack in your lab section channel.
3. The object is not simply to get the job done, but to get it done in the way that is asked
for in the lab. The objective is not just to get the code working, but to have a deep
understanding of why it is working.
4. Any cheating case will be reported to the Disciplinary Committee without any delay.
5. Failure to adhere to the naming convention of the file will result in 2.5 marks deduction.
6. Failure to adhere to coding conventions of the file will also result in 2.5 marks
deduction.
Coding Conventions:
● Constants are “ALLCAPS” or “ALL_CAPS”.
● Variables are “allsmall” or “all_small”.
● All function names must be “firstWordSmallAllOtherWordsCamelCase”.
● All curly brackets defining a block must be vertically aligned.
● File naming: PreLab04_YourRollNo
Learning Objective:
● Use of integer and double data types
● Practice mathematical operations
Task 1: [10 marks]
Write a program that uses price of different products in Rupees and displays the price in Dollar
and Yen. Your display should look like the one shown below. Dollar should be correct to 3
significant figures and Yen should be correct to 2 decimal places. Read Lab Manual or consult
lecture recording for explanations.
(Hint: Read Lab Manual and ask Tas on Slack. Use cout.unsetf(ios::fixed) to unset the fixed
flag to print dollar correct to 3 significant figures and then use fixed keyword again to print Yen
correct to 2 decimal places).
1 Rupee = 0.0059 Dollar = 0.65 Yen
Products Rupees
Burger 160
Pizza 355
Cold drink 45
Steps
Store the product costs (Burger=160, Pizza=355, Cold Drink=45) in variables of suitable
types
Use I/O Manipulators to print the table headers “Products”, “Rupees”, “Dollars”, “Yen”.
Then print the values of each of the products in three currencies, again using I/O
Manipulators for spacing, and also using other tools mentioned in Lab Manual and
taught in the lecture to make sure that the dollar value is printed upto 3 decimal places
and the yen value is printed upto 2 decimal places.
Sample output:
Steps
1. Store the following string
“Mission successful.
Regards,”
Sample output:
(Hint: Use ascii encoding. You can seperately convert each characters in your name to interger
ascii code and print the integer value with space in between. Read Lab Manual for explanation
of how to do that.)