**Programming and Problem Solving I Lab**

Assignment 2 – 100 points (Pseudocode – 40, Source Code – 60)

What students will learn:

- Problem solving
- Basic program structure
- Input and output with the user
- Basic calculations

Academic Policies: don’t cheat. Come see us instead – we’re here to help.

** Problem 1:**Well, it ain’t a Picasso:

A local painting company has asked you to create an algorithm to help them figure out how much paint they need for each job when they are giving estimates.

A single gallon of paint will cover 400 square feet of wall. You need to ask the customer how many walls they need painted, the average height and width of each wall and what color paint they want used.

After getting the inputs, your algorithm should determine and display the total square feet of the walls to be painted along with how many gallons of the desired color paint that the job would require.

*Note: Area of a rectangle is length * width so it would be height * width for a wall.*

__Sample Output:__

How many walls would you need painted? 2

What is the average height? 10

What is the average width? 10

What color paint do you want? Purple

Painted 200 ft^2 of wall the color Purple

It took 0.5 gallons of paint

__ __

** Program 2: **Pythagorean Theorem:

The KSU Math department has asked you to help them by writing an algorithm to grade tests more quickly when the questions involve the Pythagorean Theorem (a^{2 }+ b^{2} = c^{2}).

Write your program to get the values for the two sides of the triangle (a & b) and then calculate and display the length of the hypotenuse (c) using the formula.

* *

*Note: C# uses Math.sqrt(), C++ uses sqrt() and Java uses Math.sqrt(), put the value you want the square root of inside the parentheses. *

__Sample Output:__

What is side A’s length? 5

What is side B’s length? 5

Hypotenuse is: 7.0710678118654755

__Sample Output #2:__

What is side A’s length? 10

What is side B’s length? 10

Hypotenuse is: 14.142135623730951

__ __

** Program 3: **Help for Australia:

Due to the wildfires in Australia, the Red Cross has asked for assistance in determining how many trees were destroyed per hectare. Australia has a tree density of 456 trees per acre. A hectare is equal to 2.47 acres.

Write the algorithm that determines the conversion from acres to hectares then gets the user’s input on how many hectares were destroyed on a given day. Then print the total number of trees destroyed by fires based on the information entered by the user and the conversion calculation.

__Sample Output:__

How many hectares were destroyed today? 2

This many trees were destroyed: 2252.6400000000003

__Sample Output #2:__

How many hectares were destroyed today? 10

This many trees were destroyed: 11263.2

__Sample Output #3:__

How many hectares were destroyed today? 50

This many trees were destroyed: 56316.00000000001

__ __

__ __

__Submission:__

- Review the assignment submission requirements and FYE polices.
- Upload the pseudocode files (Word doc or PDF) to the Assignment 2 – Pseudocode submission folder in Gradescope once it opens.
- Upload the source code files to Assignment 2 – C++/C#/Java Source Code submission folder in Gradescope once it opens.
- The files must be uploaded to Gradescope by the due date.

Last Updated on