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

Fahrenheit to Centigrade Conversion Lab Report - Prof. Purushotham V. Bangalore, Lab Reports of Computer Science

A lab report on converting temperatures from fahrenheit to centigrade scale. It includes problem specification, program design, testing plan, test cases, analysis and conclusions, and references. The author, purushotham v. Bangalore, is a student in cs 201 introduction to object oriented programming, and the lab instructors are y. Sun and f. Javed. The document was created on january 27, 2004.

Typology: Lab Reports

2009/2010

Uploaded on 04/12/2010

koofers-user-st8
koofers-user-st8 🇺🇸

10 documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download Fahrenheit to Centigrade Conversion Lab Report - Prof. Purushotham V. Bangalore and more Lab Reports Computer Science in PDF only on Docsity! Fahrenheit to Centigrade Conversion LAB #1 By Purushotham V. Bangalore CS 201 Introduction to Object Oriented Programming Lab Section # F1 Lab Instructors: Y. Sun and F. Javed Jan 27, 2004 Problem Specification Write a program that will read temperature in Fahrenheit scale, converts it to Centigrade scale, and print the values of temperature in Fahrenheit and Centigrade scales. The program must work on positive and negative values and accept decimals. Program Design In order to solve the given problem we need to perform the following steps: a) read in a floating point number b) compute the corresponding value in centigrade scale c) display the input and computed value We can read a number using the Keyboard class provided in the text book. Conversion from Fahrenheit to Centigrade scale can be performed using the formula C = 5/9 * (F – 32), where F is the temperature in Fahrenheit scale and C is the corresponding temperature in Centigrade scale. The display can be done using the println method of the System.out object. Testing Plan There are 3 main steps in the program and we should test all 3 steps. Step (c) is simple since we are relying on System class. We can test Step (a) by printing the values read to make sure the value read using the Keyboard class is the one we entered. Step (b) is the most important piece that requires good test cases. By looking at the formula we can observe that if F=32, then C=0 and if F=0, C=5/9*(-32)=-17.78 (if we round off at 2 significant digits). Similarly we can determine that F=100 gives C=37.78 and F=212 gives C=100. Test Cases The test cases are shown in the table below: Test Case Number Input Values Expected Output Values 1 32 0 2 212 100 3 100 37.78 4 0 -17.78 Analysis and Conclusions Conversion of temperatures from Fahrenheit scale to Centigrade scale was accomplished using the formula C = 5/9*(F – 32). It is important to declare the different variables with the correct type in order to get the correct result. Also correct translation of the formula into Java language is essential to get correct results. Computing the expected results by hand before writing and testing the program allowed us to make sure the results of the program were correct. References The Keyboard class provided as part of the text book (downloaded from URL), the text book, and the formula provided in the assignment were used to do this lab assignment. 1
Docsity logo



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