It1050 Lab 3 C#

Submitted by: Submitted by

Views: 10

Words: 365

Pages: 2

Category: Science and Technology

Date Submitted: 08/30/2015 09:44 AM

Report This Essay

1050 Programming Logic

Lab 3 (20 points total)

Name:

Paste your code and screenshots below.

1. Compare and contrast the if single-selection statement and the while repetition statement. How are these two statements similar? How are they different? (2 Points).

The if single-selection statement selects or ignores a single action. It performs an action only when the condition is true. The while repetition statement is similar in that it performs the action while the statement continues to be true. It keeps repeating until the action proves to be false.

2. Declare two int variables: 1) speedLimit and 2) speed. Assign values speedLimit=35 and speed=42. Write an if statement that displays “SLOW NOW” if speed is greater than speedLimit. (2 points)

3. if-else statement - Write a program that declares and assigns a value to a Boolean variable called isTrue. Use a condition to output “It is True!” or “It is False!” based on the assigned value. Paste your code and screenshots of your program running with both true and false values (3 points).

4. if statement - Write a program that converts a Fahrenheit temperature to Celsius. The user should be able to input the temperature at the Command prompt and it should output the temperature. In addition, you should output “It is cold” if the Fahrenheit value is less that 40 or it should output “It is hot” if the temperature is over 90 (4 points). Code to read a value: double fahrenheit = Convert.ToDouble(Console.ReadLine()); Code to convert: celsius = (fahrenheit - 32d) * 5d / 9d;

I really struggled with this one and kept going back to the book trying to understand the Convert.ToDouble and just didn’t get it. I did a lot of research on the Internet and found something that made sense to me and wrote it this way. I understand if I don’t get it correct but this is what I understood and could write.

5. Write a while loop that outputs values 1-10. Increment by 1 (3 points)....