For all of these questions, you are not allowed to use the following keywords in your solution: if, else, switch, while, do, for, and the ?: operator. No credit will be given if this rule is violated.
Write a simple program that asks the user to enter the radius of a sphere in meters, and calculates the volume of the sphere. Display the result correct to three decimal places.
$ ./lab1q1 Enter radius of sphere in m: 5.67 The volume is: 763.551 m^3 $
Assuming that the name of the executable file is lab1q2, sample run(s) of the program are shown below. User input is denoted in bold.
$ ./lab1q2 Enter restaurant price before taxes: $100 Price before Taxes: $ 100.00 10% Service Charge: $ 10.00 -------- Sub-Total: $ 110.00 -------- 7% GST on $ 110.00: $ 7.70 -------- Price after Taxes: $ 117.70 -------- $ ./lab1q2 Enter restaurant price before taxes: $2345.67 Price before Taxes: $2345.67 10% Service Charge: $ 234.57 -------- Sub-Total: $2580.24 -------- 7% GST on $2580.24: $ 180.62 -------- Price after Taxes: $2760.85 -------- $Deduce as much as you can about the program and what it does from the sample runs above. Then, write a program called lab1q2.c that follows the sample runs precisely.
Hint: To print the % symbol, use %% in the printf format string.
Crossfire is a free multiplayer adventure game. In this game, 1 platinum = 5 gold = 10 silver. Write a simple program that converts x amount of silver coins to the equivalent amount of platinum, gold, and silver coins. The equivalent amount should have as few coins as possible.
Assuming that the name of the executable file is lab1q3, sample run(s) of the program are shown below. User input is denoted in bold.
$ ./lab1q3 Enter number of silver coins: 5 5 silver coin(s) is equivalent to: 0 platinum coin(s) 2 gold coin(s) 1 silver coin(s) $ ./lab1q3 Enter number of silver coins: 197 197 silver coin(s) is equivalent to: 19 platinum coin(s) 3 gold coin(s) 1 silver coin(s) $
A total of 21 different hosts have accessed this document in the last 444 days; your host, nsrp-source.comp.nus.edu.sg, has accessed it 7 times.
If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.