___Assignment 1 Part B___
docx
keyboard_arrow_up
School
Centennial College *
*We aren’t endorsed by this school
Course
120
Subject
Industrial Engineering
Date
Feb 20, 2024
Type
docx
Pages
11
Uploaded by AgentJellyfish19389
ASSIGNMENT-1
{PART-2}
Task 1:
After surveying a number of new-home electrical installations, Kelly Builder’s Inc. has worked out what the length of wire a typical house would require. Write a program that will prompt the user for the average length required for a home and the number of houses to wire. The program will then calculate and display the total length of wire required for the specified number of houses.
IPO Information
C# Statement
Input
:
averageLengthRequired
numberOfHouses
Output
:
totalLengthRequired
Processing
Algorithm:
1.
Prompt for averageLengthRequired
2.
Accept the averageLengthRequired
3.
Prompt for numberOfHouses
4.
Accept the numberOfHouses
5.
Calculate the totalLengthRequired
by multiplying averageLengthRequired
by
numberOfHouses
6.
Display totalLengthRequired
//Input
double averageLengthRequired;
int numberOfHouses;
//Output
double totalLengthRequired;
//Algorithm
Console.WriteLine(
"What is the average length of wires required for a home in meters: "
) ;
averageLengthRequired = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Number of Houses: "
);
numberOfHouses = Convert.ToInt32(Console.ReadLine());
totalLengthRequired = averageLengthRequired *
numberOfHouses;
Console.WriteLine(
"The total length required of wires for " + numberOfHouses + " house(s) is " +totalLengthRequired + " meters"
) ;
Desk Checking
averageLengthRequired
(m)
numberOfHouses
totalLengthRequired (m)
20
5
20 * 5 = 100
Task 2
: Loreto Farms wants a program to estimate the cost of fertilizing their fields for the coming year. The program will prompt the user for the rate of fertilizer application (how many kg per hectares), the unit price of fertilizer (dollars per kg) and the size (hectares)of land to be cultivated and then calculate
and display the cost.
IPO Information
C# Statement
Input
:
fertilizerRate
priceOfFertilizer
hectaresOfLand
Output
:
totalPrice
Processing
:
total
Algorithm:
1. Prompt for fertilizerRate
2. Accept the fertilizerRate
3. Prompt for priceOfFertilizer
4. Accept the priceOfFertilizer
5. Prompt for hectaresOfLand
6. Accept the hectaresOfLand
7. Calculate total
by multiplying heactaresOfLand
by fertilizerRate
8. Calculate totalPrice
by multiplying total
by priceOfFertilizer
//Input
double fertilizerRate;
double priceOfFertilizer;
double hectaresOfLand;
//Output
double totalPrice;
//Processing
double total;
//algorithm
Console.WriteLine(“ R
ate of fertilizer application?: "
);
fertilizerRate = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"What is the price of fertilizer (dollars per kg): "
);
priceOfFertilizer = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"How is the size of farm (hectares): "
);
hectaresOfLand = Convert.ToDouble(Console.ReadLine());
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
9. Display totalPrice
total = hectaresOfLand * fertilizerRate;
totalPrice = Convert.ToInt32(total * priceOfFertilizer);
Console.WriteLine(
"The total price for the fertilizer is: " + totalPrice);
fertilizerRate
priceOfFertilizer
hectaresOfLand
total
totalPrice
4
25
12
4
1200
Task 3
: Parker would like to get each of the females in his family the same gift for the holidays. He has an amount of money which he is willing to use up completely. Write a program that will prompt him for the price of the item and the amount of money that he has and then calculate and display the most items that he can buy and the left-over money. (There are 2 outputs for this question)
IPO Information
C# Statements
Input
:
amountOfMoney
price
Output
quantity
leftOverMoney
Processing
totalPrice
Algorithm
1. 1. Prompt for amountOfMoney
2. 2. Accept the amountOfMoney
3. 3. Prompt for price
4. 4. Accept the price
5. Calculate and round the quantity
to the nearest integer by dividing the price
from the amountOfMoney
//Input
double amountOfMoney;
double price;
//Output
double quantity;
double leftOverMoney;
//Processing
double totalPrice;
//Algorithm
Console.WriteLine(
"What is the amount of money?"
);
amountOfMoney = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"What is the price of the item?"
);
price = Convert.ToDouble(Console.ReadLine());
quantity = amountOfMoney / price;
quantity = (Math.Truncate(quantity));
(
amountOfmoney
/ price
)
6. Calculate the totalPrice
by multiplying the quantity
by the price
7. Calculate the leftOverMoney
by subtracting the totalPrice
from the amountOfMoney
8. Display the quantity
9. Display the leftOverMoney
totalPrice = quantity * price;
leftOverMoney = amountOfMoney - totalPrice;
Console.WriteLine(
"The total amount of objects are: " + quantity + "."
);
Console.WriteLine(
"The left-over money is: $" + leftOverMoney + "."
);
Desk Checking
amountOfMoney($)
price ($)
totalPrice($)
quantity
leftOverMoney($)
315
25
300
12
15
Task 4:
Quincy “The Plumber” bills customer for pipe installation based on the length as well as the number of joins of the job. Build a program that will prompt for length rate, join rate, the length, the number of join and calculate and
display the total cost. [cost = (length * lengthRate) +
(numberOfJoins * joinRate)]
IPO Information
C# Statement
Input
:
//Input double lengthRate;
lengthRate
joinRate
lengthOfPipe
numberOfJoins
Output
:
totalCost
Processing
:
lengthCost
joinCost
Algorithm
:
1.Prompt for lengthOfPipe
2.Accept the lengthOfPipe
3.Prompt for lengthRate
4.Accept the lengthRate
5.Prompt for joinRate
6.Accept the joinRate
7.Prompt for numberOfJoins
8.Accept the numberOfJoins
9.Calculate the lengthCost
by multiplying
lengthRate
and joinRate
10.Calculate joinCost
by multiplying length
and numberOfJoins
11.Calculate the totalCost
by adding lengthCost
and JoinCost
12.Display totalCost
double joinRate;
double length;
int numberOfJoins;
//Output
double totalCost;
//Processing
double lengthCost;
double joinCost;
//Algorithm
Console.WriteLine(
"Enter the length of the pipe: "
);
length= Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter the length rate: "
);
lengthRate = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter the join rate: "
);
joinRate = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter of number of joins: "
);
numberOfJoins = Convert.ToInt32(Console.ReadLine());
lengthCost = lengthRate * joinRate;
joinCost = length * numberOfJoins;
totalCost = lengthCost + joinCost;
Console.WriteLine(
"The total cost of the pipe installation is:$ " + totalCost);
Desk-Checking
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
lengthOfPipe
lengthRate
joinRate
numberOfJoins
lengthCost
joinCost
totalCost
1.0
2.5
10.0
3
2.5 * 10 = 25
1.0 * 3.0
= 3.0
25.0 + 3.0
=28.0
Task 5
: Stephanie’s Confectionary wants a program that will prompt the user for the price of the candy and the amount of money she would like to spend and then calculate and display the amount of candies that can be purchased as well as the amount of money remaining after purchase.
IPO Information
C# Statements
Input
:
candyPrice
moneyAvailable Output
:
numberOfCandies
remainingMoney
Processing
:
Algorithm
:
1.
Enter candyPrice
2.
Accept the candyPrice
3.
Enter moneyAvailable
4.
Accept moneyAvailable
5.
Calculate numberOfCandies
= moneyAvailable
/ candyPrice
6.
Calculate remainingMoney
= moneyAvailable
- (
numberOfCandies
* candyPrice
)
7.
Display the numberOfCandies
8.
Display the remainingMoney
//input values
double candyPrice;
double moneyAvailable;
//Output int numberOfCandies;
double remainingMoney;
//Algorithm
Console.WriteLine(
"Enter the price of the candy: $ "
);
candyPrice = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter the money available: $ "
);
moneyAvailable = Convert.ToDouble(Console.ReadLine());
numberOfCandies = Convert.ToInt32(moneyAvailable / candyPrice);
remainingMoney = moneyAvailable - (numberOfCandies * candyPrice);
Console.WriteLine(
"Number of candies that can be purchased: " + numberOfCandies);
Console.WriteLine(
"Amount of money remaining after purchase: $ " + remainingMoney);
Desk-Checking
candyPrice ($)
moneyAvailable ($)
numberOfCandies
remainingMoney ($)
4.5
20.0
4
2.0
Task 6
: Thomas’ Towing Services would like an application that calculates and display the cost of a towing job. The cost is based on the towing rate, the distance as well as a flat service rate. The service rate is the same regardless of the towing distance and it is always applied in any job.
IPO Information
C# Statements
Input
:
towingRate
distance
serviceRate
Output
:
towingCost
Processing
:
netCost
Algorithm
:
1.
Prompt for towingrate
2.
Accept the towingRate
3.
Prompt for distance
4.
Accept the distance
5.
Prompt for serviceRate
6.
Accept the serviceRate
7.
Calculate netCost
by adding serviceRate
& towingRate
8.
Calculate towingCost
by multiplying netCost
by distance
//Input
double towingRate;
double distance;
double serviceRate;
//Output
double towingCost;
//Processing
double netCost;
//Algorithm
Console.WriteLine(
"Enter the towing rate: "
);
towingRate = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter the distance: "
);
distance = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter the service rate: "
);
serviceRate = Convert.ToDouble(Console.ReadLine());
netCost = towingRate + serviceRate;
towingCost = distance * netCost;
9.
Display towingCost
Console.WriteLine(
"Cost of the towing job:$ " + towingCost);
Desk-Checking
towingRate ($)
distance (m)
serviceRate ($)
towingCost ($)
5.0
14.0
20.5
357
Task 7
: Duct Airlines would like a program that will calculate and display the cost of flying an aircraft between various locations. Write a program that will compute the cost which is based on the fuel efficiency (amount of fuel used for each km traveled) of the aircraft, the unit price of fuel and the length of the journey.
IPO Information
C# Statements
Input
:
fuelEfficiency
fuelPrice
length
Output
:
cost
Processing
:
Algorithm
:
1.
Prompt for fuelEfficiency
2.
Accept the fuelEfficiency
3.
Prompt for fuelPrice
4.
Accept the fuelPrice
5.
Prompt for length
6.
Accept the length
//Input
double fuelEfficiency;
double fuelPrice;
double length;
//Output
double cost;
//Processing
//Algorithm
Console.WriteLine(
"Enter the amount of fuel used per km: "
);
fuelEfficiency = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter the price of the fuel per unit: $ "
);
fuelPrice = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter the length of the journey: "
);
length = Convert.ToDouble(Console.ReadLine());
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
7.
Calculate cost
by multiplying fuelEfficiency
, fuelPrice
and length
8.
Display cost
cost = fuelEfficiency * fuelPrice * length;
Console.WriteLine(
"The cost of the journey is: $ "
);
Desk-Checking
fuelEfficiency (l per km)
fuelPrice ($)
length (km)
cost ($)
0.023
24.3432
2000
1,119.7872
Task 8:
Othello’s Grocery is a small business located in the West Hill area. They would like a program that will prompt the user for the weight and price of the produce, the price and capacity of plastic bag and then calculate and display the total cost of the sale. You may assume that all customers will require bags.
IPO Information
C# Statements
Input
:
productWeight
unitPrice
bagPrice
bagCapacity
Output
:
totalCost
Processing
:
price1
price2
Algorithm:
1. Enter the productWeight
2. Accept the productWeight
//Input
double productWeight;
double unitPrice;
double bagPrice;
double bagCapacity;
//Output
double totalCost;
//Processing
double price1;
double price2;
//Algorithm
Console.WriteLine(
"Enter product Weight(kg): "
);
productWeight = Convert.ToDouble(Console.ReadLine());
3. Enter the unitPrice
4.Accept the unitPrice
5. Enter the bagCapacity
6. Accept the bagCapacity
7.Enter the bagPrice
8. Accept the bagPrice
9. Calculate price1
by multiplying productWeight
and
unitPrice
10. Calculate price2
by multiplying bagPrice
and bagCapacity
11. Calculate the totalCost
by adding price1
and price2
12. Display totalCost
Console.WriteLine(
"Enter unit price:$ "
);
unitPrice = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter bag capacity(L): "
);
bagCapacity = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(
"Enter unit price of bag:$ "
);
bagPrice = Convert.ToDouble(Console.ReadLine());
price1 = productWeight * unitPrice;
price2 = bagCapacity * bagPrice;
totalCost = price1 + price2;
Console.WriteLine(
"Total Cost:$ " + totalCost);
Desk-Checking
productWeight
(kg)
unitPrice ($)
bagPrice ($ /L)
bagCapacity
(L)
price1 ($)
price2 ($)
totalCost ($)
5
1.5
0.5
3
5 * 1.5 =
7.5
0.5 * 3 =
1.5
9