Question
Using C++
cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user to enter two numbers. The progzan should use the conditional operator to determine which number is the smaller and which is the larger. Display your output in the format below: The smaller number is: (smallerNumber) The larger number is: ClargerNumber] b) Areas of Rectangles: The area of a rectangle is calculated by maltiplying its length tines its width. Write a program that asks the user for the length and the width of two rectangles. The program should display to the user which rectangle has the greater area or if the areas are the same e) Body Mass Index: Write a progran that calculates and displaysa persons body nass index MI) when the user provides their weight and height. The RMT is often used to deternine whether a person is overveight or underweight for his or her height A pezsons RMT is calculated with the following formular -Cweight in Jbe 703)/ (height in inches) Wheze weights measured in pounds and height is measured in inches. The progran should display a nessage indicating whether the person has optimal weight (ME between 18.5 and 25 inclusive), is underveight (BMI less than 18.5), E is overweight ( greater than 25) The peogzam should also display the caleulated H
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MaxMin.cpp

#include<iostream>

using namespace std;

int main()

{

// variables declaration

int first,second;

// getting two numbers from user

cout<<"Enter first number: ";

cin>>first;  

cout<<"Enter second number: ";

cin>>second;

// comparing both numbers using conditional operator

if(first>second)

{

cout<<endl<<"The smaller number is: "<<second<<endl;

cout<<"The larger number is: "<<first<<endl;

}

else

{

cout<<endl<<"The smaller number is: "<<first<<endl;

cout<<"The larger number is: "<<second<<endl;

}

return 0;

}

Output

고 CAUsersiAKSHAVDesktop.MaxMin.exe Enter first number: 56 Enter second number: 34 The smaller number is: 34 The larger number is: 56

AreaOfRect.cpp

#include<iostream>

using namespace std;

int main()

{

// variables declaration

int length,width,length2,width2;

//getting length and width for two rectangles

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

cin>>length;

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

cin>>width;

int area=length*width; // calculating area of first rectangle

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

cin>>length2;

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

cin>>width2;

int area2=length2*width2; // calculating area of second rectangle

cout<<endl<<"Area of first rectangle is: "<<area<<endl;

cout<<"Area of second rectangle is: "<<area2<<endl;

// checking which area is greater or both are same

if(area>area2)

cout<<"First rectangle has greater area."<<endl;

else

if(area<area2)

cout<<"Second rectangle has greater area."<<endl;

else

cout<<"Both rectangles has same area."<<endl;

return 0;

}

Output

BMI.cpp

#include<iostream>

using namespace std;

int main()

{

//variables declaration

float height,weight;

// getting height and weight from user

cout<<"Enter height: ";

cin>>height;

cout<<"Enter weight: ";

cin>>weight;

// calculating BMI

float bmi=(weight*703)/(height*height);

cout<<endl;

// checking person is optimal weight, under weight or over weight

if(bmi>=18.5 && bmi<=25)

cout<<"The person has optimal weight"<<endl;

else

if(bmi<18.5)

cout<<"The person is underweight"<<endl;

else

if(bmi>25)

cout<<"The person is overweight"<<endl;

cout<<"BMI is "<<bmi<<endl;

return 0;

}

Output

Add a comment
Know the answer?
Add Answer to:
Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C++, Write a program that will provide the user a menu from which the user...

    Using C++, Write a program that will provide the user a menu from which the user may select to calculate the area of one of four geometric shapes: a circle, a rectangle, a triangle, and a trapezoid. You should use the most appropriate SWITCH block for this program. The user will input all data needed to calculate the area. The program should output all data input by the user, the calculated area, and the geometric shape selected. Run this program...

  • Make a program using Java that asks the user to input an integer "size". That integer...

    Make a program using Java that asks the user to input an integer "size". That integer makes and prints out an evenly spaced, size by size 2D array (ex: 7 should make an index of 0-6 for col and rows). The array must be filled with random positive integers less than 100. Then, using recursion, find a "peak" and print out its number and location. (A peak is basically a number that is bigger than all of its "neighbors" (above,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT