Question

In: Computer Science

ask the user for the length and width of ywo rectangles. tell the user the area...

ask the user for the length and width of ywo rectangles. tell the user the area of the reftangle with the greater width.

C++

Solutions

Expert Solution

program:

#include <iostream>

using namespace std;

int main()
{
int l1,l2,w1,w2;
int area1,area2;

//Enter length and width of rectangle1
cout<<"Enter length of rectangle1:";
cin>>l1;
  
cout<<"Enter width of rectangle1:";
cin>>w1;
  
//Enter length and wisth of ractanle2
cout<<"Enter length of rectangle2:";
cin>>l2;

cout<<"Enter width of rectangle2:";
cin>>w2;
  
if(w1>w2) //if width of ractangle1 is greater than width of rectangle2
{
area1=l1*w1; //then calculate area of rectangle1
cout<<"Area of rectangle1 is:"<<area1;
}
else //if width of reactangle2 is greater than width of reactangle1
{
area2=l2*w2; //then calculate area of rectangle2
cout<<"Area of Rectangle2 is:"<<area2;
}
return 0;
}

output:


Related Solutions

1. Write a Python program that will ask the user length and width of the right...
1. Write a Python program that will ask the user length and width of the right triangle and find the area of the right-angled triangle. The formula for finding the area of a right-angle triangle is ab/2. Also, find out the result if you calculate as (ab)/2. Is it the same? If it is same, why it is the same. If it is not the same, why it is not the same.
a function named area to calculate the area of a rectangle area = Length x width...
a function named area to calculate the area of a rectangle area = Length x width 2.a function named volume to calculate the volume of a sphere volume = 4/3 x 3.14 x radius x radius x radius 3.a function named volume to calculate the volume of a cuboid volume = Length x width x ht 4. Use a loop structure to calculate the sum of all odd numbers from 1 to 17 5) Use a loop structure to calculate...
3. a) Write a script to prompt the user for the length and width of a...
3. a) Write a script to prompt the user for the length and width of a rectangle, and print its area with two decimal places. Put comments in the script. b) Convert the script in part (a) to a function.
C++ Question: write a program that prompts the user for the length and width of a...
C++ Question: write a program that prompts the user for the length and width of a rectangle in inches.  The program then uses functions to compute the perimeter and area of the rectangle and to convert those to meters and square meters respectively. Sample output from one instance of the program is shown below: ```html Welcome to the Foot-To-Meter Rectangle Calculator ================================================= Enter the rectangle length in feet: 2 Enter the rectangle width in feet: 3 The rectangle dimensions are: 0.61...
1.Given the function f(x)=1/x, using 3 rectangles of equal width, find an approximation to the area...
1.Given the function f(x)=1/x, using 3 rectangles of equal width, find an approximation to the area between the curve and the x-axis over the interval [4,8] if the heights of the rectangles are found by evaluating the function at the left endpoints, right endpoints, and midpoints of each subinterval created by a partition of the interval given. 2. Given the function, f(x)=−x3+6x2 using 6 rectangles of equal width, find an approximation to the area between the curve and the x-axis...
Find the length and width of a rectangle whose perimeter is 21 meters and whose area...
Find the length and width of a rectangle whose perimeter is 21 meters and whose area is 20 square meters. Assign variables to the unknown(s)... Form a system of equations... Solve the system and state your answer in the context of the problem, show all steps clearly, be sure to check your answers:
Ask the user for a filename, then ask the user for a line of text. Write...
Ask the user for a filename, then ask the user for a line of text. Write the line of text the filename specified by the user. The filename may be absolute or relative to the project directory.
Flowchart + Python. Ask the user for a value. Then, ask the user for the number...
Flowchart + Python. Ask the user for a value. Then, ask the user for the number of expressions of that value. Use While Loops to make a program. So then, it should be so that 5 expressions for the value 9 would be: 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 Flowcharts and Python Code. Not just Python code. I cannot read handwriting....
Write code to ask user to provide input length in miles, yards, feet and inches and...
Write code to ask user to provide input length in miles, yards, feet and inches and write code to convert sum of total length into meters. Display result by reiterating input values in inches, feet, yards, and miles entered by user, and the sum of the total length in meters. PLEASE use bluej for code
Find the length and width of the parabolic cylinder.
Let's suppose that you want to cook 1 lb of hot dogs using a parabolic trough concentrator on a clear June day in Los Angeles. The hot dogs would be skewered on a stiff piece of wire and aligned along the axis of the trough in the same position in which the absorber/receiver normally would be placed. The desired cooking time is 10 mins, with the resulting surface temperature of the hot dog about 450 F.Find the length and width...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT