Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Areas of Rectangles The area of a rectangle is the rectangles length times its w

ID: 3690195 • Letter: A

Question

Areas of Rectangles The area of a rectangle is the rectangles length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectan-gle has the greater area, or if the areas are the same. Mass and Weight Scientists measure an object's mass in kilograms and its weight in newtons. If you know an object's mass, you can calculate its weight in newtons with the following formula: weight 0 mass 9.8 Write a program that asks the user to enter an object's mass, and then calculates and displays its weight If the object weighs more than 1000 newtons, display a message indicating that it is too heavy. If the object weighs less than 10 newtons, display a message indicating that the object is too light.

Explanation / Answer

3.1

#include<iostream.>

int main()

{

int wid1,wid2,lengt1,lengt2;

float rect1,rect2;

cout << "Enter inches width of first rectangle: ";

cin >> wid1;

cout << "Enter inches length of first rectangle: ";

cin >> lengt1;

cout << "Enter inches width of second rectangle: ";

cin >> wid2;

cout << "Enter inches length of second rectangle: ";

cin >> lengt2;

rect1 = wid1 * lengt1;

rect2 = wid2 * lengt2;

if (rect1 > rect2)

{

cout << "Rectangle 1 is " << rect1 - rect2<< " area inches larger than rectangle 2 ("<< rect2 << ")." ;

}

else if (rect1 < rect2)

{

cout << "Rectangle 2 is " << rect2 - rect1<< " area inches larger than rectangle 1 ("<< rect1 << ")." ;

}

else if (rect1 == rect2)

{

cout << "Rectangles 1 and 2 are equal at "<< rect1 << " area inches." ;

}

return 0;

}

3.2

#include<iostream>

int main()
{
double mass,weight;
cout<<”enter the mass”;
cin>>mass;
weight=mass*9.8;
cout<<”the weight is =”<<weight;
if(weight>1000)
{
cout<<the weight is too heavy”;
}
else if(weight<10)
{
cout<<”the weight is too light”;
}
else
{
cout<<”the weight is in between 10 and 1000”;
}

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote