Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Language. I have accidentally used a different prompt and someone answered the question by using a switch statement, I would like to change it

C++ Language.

I have accidentally used a different prompt and someone answered the question by using a switch statement, I would like to change it to an if else statement, please. Also, including a string as well.

This was the answer with the wrong prompt.

Can anyone please change it, please...

image text in transcribedimage text in transcribedimage text in transcribed

#include

using namespace std;

//function declaration

void sort(int& a,int& b,int& c);

int main()

{

int a,b,c;

cout

cin>>a;

cout

cin>>b;

cout

cin>>c;

sort(a,b,c);

cout

char ch;

int num;

cout

cout

cout

cout

cout

cin>>ch;

switch(ch)

{

case 'A':

case 'a':

{

num=30000;

cout

break;

}

case 'B':

case 'b':

{

num=1000;

cout

break;

}

case 'C':

case 'c':

{

num=40000;

cout

break;

}

case 'D':

case 'd':

{

num=2480000;

cout

break;

}

default:{

cout

break;

}

}

return 0;

}

//Function implementation which sorts the 3 numbers in ascending order

void sort(int& a,int& b,int& c)

{

//Declaring variable

int temp;

/* Checking whether first number is greater

* than second number or not

* if yes, Swapping will happen

*/

if( a>b )

{

temp = a;

a = b;

b = temp;

}

/* Checking whether second number is greater

* than third number or not

* if yes, Swapping will happen

*/

if( b>c )

{

temp = b;

b = c;

c = temp;

}

/* Checking whether first number is greater

* than second number or not

* if yes, Swapping will happen

*/

if( a>b )

{

temp = a;

a = b;

b = temp;

}

}

CS 215- Fall 2018 Lab 2 Learning Objectives: More practice with user input/output, including string input. Use of if/else, possibly nested, to solve simple problems. General Description 1. Write a program that asks the user to enter 3 numbers, one at a time. Print the three numbers in sorted order. [Note: no need to use an array or similar structure!] Examples (user input in blue) Enter number 1: 45 Enter number 1: 55 Enter number 2: 45 Enter number 3: 35 Sorted they are 35 4555 Enter number 2: 35 Enter number 3: 55 Sorted they are 35 45 55 2. In the same program: Write code that will display the following menu A. Aleppo Pepper B. Banana Pepper C. Cayenne Pepper D. Dragons Breath Enter a letter to choose a pepper: Calculate the Scoville Units (measure of hotness) Aleppo 30,000 Banana 1,000 Cayenne40,000 Dragon's Breath 2,480,000 Print the Scoville Units for the chosen pepper, example That' s 1000 Scovilles of heat

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions