Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSE 5A Homework 3: Temperature Conversion Program, Assignments of Computer Science

The instructions for homework 3 in the cse 5a introduction to programming course. Students are required to create a new folder, write a c source file named hw3.c, and implement a temperature conversion program using scanf(), if-else statements, and for loops. The program should ask the user for the number of conversions and the temperature to convert, as well as whether it's fahrenheit or celsius. The temperature conversions are then performed using the provided formulas and output with the specified format.

Typology: Assignments

2009/2010

Uploaded on 03/28/2010

koofers-user-d9p
koofers-user-d9p ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

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.
Docsity logo



Copyright ยฉ 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved