Question
C++ language This is the last answer I got but I would like to use a string instead of char please help me... #include using
C++ language
This is the last answer I got but I would like to use a "string" instead of "char" please help me...
#include
using namespace std;
//function declaration
void sort(int& a,int& b,int& c);
int main()
{
int a,b,c;
cout"Enter number 1:";
cin>>a;
cout"Enter number 2:";
cin>>b;
cout"Enter number 3:";
cin>>c;
sort(a,b,c);
cout"Sorted they are :"a" "b" "cendl;
char ch;
int num;
cout" A.Aleppo Pepper"endl;
cout"B.Banana Pepper"endl;
cout"C.Cayenne Pepper"endl;
cout"D.Dragons Breath"endl;
cout"Enter a letter to choose a pepper :";
cin>>ch;
if( ch == 'a' || ch == 'A' )
{
num=30000;
cout"That's "num" Scovilles of heat!"endl;
}
else if( ch == 'b' || ch == 'B' )
{
num=1000;
cout"That's "num" Scovilles of heat!"endl;
}
else if( ch == 'c' || ch == 'C' )
{
num=40000;
cout"That's "num" Scovilles of heat!"endl;
}
else if( ch == 'd' || ch == 'D' )
{
num=2480000;
cout"That's "num" Scovilles of heat!"endl;
}
else
cout"The pepper not on the list"endl;
system("pause");
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started