Download CSE 5A Homework 3: Temperature Conversion Program and more Assignments Computer Science in PDF only on Docsity! 1 CSE 5A Introduction To Programming (C/C++) Homework 3 Read Chapter 5 & 6 Due: Friday, October 19 by 6:00pm Create a new folder named HW3 (note uppercase HW3) in your cs5f@ieng9 Home Directory. You can do this via My Computer -> WebDrive drive W: cs5f@ieng9 โ Home Directory and then create a New -> Folder and name it HW3. Using Bloodshed Dev-C++, create a new Source File (File -> New -> Source File) and Save As with File Type C Source Files (*.c), File Name: hw3 (note lowercase hw3), and Save In the new W: WebDrive/HW3 folder you created above. Feel free to ask the tutors on duty in the lab for help. hw3.c will be an extension of hw2.c adding user input (scanf()), conditional (if-else), and looping (for loop). Let us start with an example execution of the program (user input is in bold): How many temperature conversions would you like to perform? 3 [#1] Enter the degree you want to convert: 44.492 Is this a Fahrenheit or Celsius temperature? [F/C]: f 44.49 F = 6.94 C [#2] Enter the degree you want to convert: 212 Is this a Fahrenheit or Celsius temperature? [F/C]: F 212.00 F = 100.00 C [#3] Enter the degree you want to convert: -100.55 Is this a Fahrenheit or Celsius temperature? [F/C]: c -100.55 C = -148.99 F This program will first ask the user how many temperature conversions to perform. Then with each temperature conversion, output the loop/iteration number (conversion #1, #2, etc.) with a prompt for the user to enter the degree to convert, whether the entered degree is Fahrenheit or Celsius, and the converted temperature similar to that of HW2. Note: The user can enter either upper-case 'F' or lower-case 'f' to indicate Fahrenheit and upper- case 'C' or lower-case 'c' to indicate Celsius. Use the formulas below to perform the conversions (same as HW2): C = (F โ 32.0) / 1.8 โ to convert a Fahrenheit temperature to Celsius F = C * 1.8 + 32.0 โ to convert a Celsius temperature to Fahrenheit Use the printf() format specifier %8.2f to output all of your double floating point variables with 2 places precision to the right of the decimal point and a total width of 8 characters right-justified. Use the scanf() format specifier %lf to input a double value (%f is for float input). Whenever you input characters with scanf(), be sure to deal with the newline character appropriately. See the class notes and lecture on Making Decisions for more details. Quick summary: whenever you read a value of any type with scanf(), insert a getchar(); as the next statement to absorb the newline character.