Hello. I'm having some issues with my code in C++ : 1. The output from the variable NumberTimes3 isn't equal to 6. It just equals zero, when the equation written is NumberTimes3 * 3 2. I got the correct output from variable TemperatureAsc but I want the output to show two decimal places, like 7.41

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello. I'm having some issues with my code in C++ :

1. The output from the variable NumberTimes3 isn't equal to 6. It just equals zero, when the equation written is NumberTimes3 * 3

2. I got the correct output from variable TemperatureAsc but I want the output to show two decimal places, like 7.41

24
25
26
27
28
29
30 std::cout << "What is the Professor's name? ";
31 std::cin>> Professor;
32
33
34
35
36 getline(std::cin, illness);
47
48
49
50
int x;
int NumberTimes3;
float TemperatureAsc;
37
38 std::cin>> pluralNoun;
51
52
53
54
39
40 std::cin>> randomWord;
41 std::cout<<"Enter a random adjective: ";
42
std::cin>> adjective;
43
44
std::cout << "Enter another random adjective: ";
45 std::cin>> adjective2;
46 std::cout<<"Enter another random word: ";
55
56
std::cout << "What is your last name? ";
std::cin>> lastName;
std::cout << "What is the illness: ";
std::cin>> illness;
57
58
59
60
61
62
63
std::cout << "Enter a plural noun: ";
std::cout<<"Enter a random word: S;
std::cin>> randomWord2;
std::cout << "Enter a random place in the world: ";
std::cin>> place;
std::cout << "Enter a random whole number: ";
std::cin>> X;
std::cout << "Enter a temperature value: ";
std::cin>> TemperatureAsc;
std::cout << "Enter a third random adjective: ";
std::cin>> adjective3;
//Write out the letter using the variables given
std::cout << "Dear " << Professor << ',' <<< '\n' << randomWord <<
<< '\n' << randomWord <<< " "<< lastName <<<" will not be attending school
today." << '\n' << "He/she has come down with " << illness << "and has a poor case of the " << pluralNoun << ".\n" <<
"Currently he/she has a " << (5.0/9.0) (TemperatureAsc-32) <<" degrees Celsius fever." << '\n' <<< "We have made an
*
appointment with the " << adjective2 << "Dr. " << randomWord2 << "\n" << "Dr. " << randomWord2 <<< " has studied for
many years in " << place << " and has << (NumberTimes3 * 3) << " degrees in medicine." << '\n' <<< "He will send you
all the information you need. Thank you!" << "\n" <<< "Sincerely," << "\n" << "Mrs. " << adjective3 << "." << '\n';
"
Closed
-rselas 7a.out
What is the Professor's name? Robert
What is your last name? James
What is the illness: Cat Fever
Enter a plural noun: sashes
Enter a random word: Grape
Enter a random adjective: poor
Enter another random adjective: Murkky
Enter another random word: Flash
Enter a random place in the world: Somalia
Enter a random whole number: 2
Enter a temperature value: 45.345
Enter a third random adjective: Cloudy
Dear Robert,
Grape James will not be attending school today.
He/she has come down with Feverand has a poor case of the sashes.
Currently he/she has a 7.414 degrees Celsius fever.
We have made an appointment with the Murkky Dr. Flash.
Dr. Flash has studied for many years in Somalia and has 0.000 degrees in medicine.
He will send you all the information you need. Thank you!
Sincerely,
Mrs. Cloudy.
~/Closed-Lab-4-rseld$ g++ main.cpp
~/Closed-Lab-4-rseld$ ./a.out
What is the Professor's name? Robert
What is your last name? James
What is the illness: Cat Fever
Enter a plural noun: sashes
Enter a random word: Grape
Enter a random adjective: poor
Enter another random adjective: Murky
Enter another random word: Flash
Enter a random place in the world: Somalia
Enter a random whole number: 2
Enter a temperature value: 45.345
Enter a third random adjective: Cloudy
Dear Robert,
Grape James will not be attending school today.
He/she has come down with Feverand has a poor case of the sashes.
Currently he/she has a 7.414 degrees Celsius fever.
We have made an appointment with the Murky Dr. Flash.
Dr. Flash has studied for many years in Somalia and has 0 degrees in medicine.
He will send you all the information you need. Thank you!
Sincerely,
Mrs. Cloudy.
~/Closed-Lab-4-rseld$
Transcribed Image Text:24 25 26 27 28 29 30 std::cout << "What is the Professor's name? "; 31 std::cin>> Professor; 32 33 34 35 36 getline(std::cin, illness); 47 48 49 50 int x; int NumberTimes3; float TemperatureAsc; 37 38 std::cin>> pluralNoun; 51 52 53 54 39 40 std::cin>> randomWord; 41 std::cout<<"Enter a random adjective: "; 42 std::cin>> adjective; 43 44 std::cout << "Enter another random adjective: "; 45 std::cin>> adjective2; 46 std::cout<<"Enter another random word: "; 55 56 std::cout << "What is your last name? "; std::cin>> lastName; std::cout << "What is the illness: "; std::cin>> illness; 57 58 59 60 61 62 63 std::cout << "Enter a plural noun: "; std::cout<<"Enter a random word: S; std::cin>> randomWord2; std::cout << "Enter a random place in the world: "; std::cin>> place; std::cout << "Enter a random whole number: "; std::cin>> X; std::cout << "Enter a temperature value: "; std::cin>> TemperatureAsc; std::cout << "Enter a third random adjective: "; std::cin>> adjective3; //Write out the letter using the variables given std::cout << "Dear " << Professor << ',' <<< '\n' << randomWord << << '\n' << randomWord <<< " "<< lastName <<<" will not be attending school today." << '\n' << "He/she has come down with " << illness << "and has a poor case of the " << pluralNoun << ".\n" << "Currently he/she has a " << (5.0/9.0) (TemperatureAsc-32) <<" degrees Celsius fever." << '\n' <<< "We have made an * appointment with the " << adjective2 << "Dr. " << randomWord2 << "\n" << "Dr. " << randomWord2 <<< " has studied for many years in " << place << " and has << (NumberTimes3 * 3) << " degrees in medicine." << '\n' <<< "He will send you all the information you need. Thank you!" << "\n" <<< "Sincerely," << "\n" << "Mrs. " << adjective3 << "." << '\n'; " Closed -rselas 7a.out What is the Professor's name? Robert What is your last name? James What is the illness: Cat Fever Enter a plural noun: sashes Enter a random word: Grape Enter a random adjective: poor Enter another random adjective: Murkky Enter another random word: Flash Enter a random place in the world: Somalia Enter a random whole number: 2 Enter a temperature value: 45.345 Enter a third random adjective: Cloudy Dear Robert, Grape James will not be attending school today. He/she has come down with Feverand has a poor case of the sashes. Currently he/she has a 7.414 degrees Celsius fever. We have made an appointment with the Murkky Dr. Flash. Dr. Flash has studied for many years in Somalia and has 0.000 degrees in medicine. He will send you all the information you need. Thank you! Sincerely, Mrs. Cloudy. ~/Closed-Lab-4-rseld$ g++ main.cpp ~/Closed-Lab-4-rseld$ ./a.out What is the Professor's name? Robert What is your last name? James What is the illness: Cat Fever Enter a plural noun: sashes Enter a random word: Grape Enter a random adjective: poor Enter another random adjective: Murky Enter another random word: Flash Enter a random place in the world: Somalia Enter a random whole number: 2 Enter a temperature value: 45.345 Enter a third random adjective: Cloudy Dear Robert, Grape James will not be attending school today. He/she has come down with Feverand has a poor case of the sashes. Currently he/she has a 7.414 degrees Celsius fever. We have made an appointment with the Murky Dr. Flash. Dr. Flash has studied for many years in Somalia and has 0 degrees in medicine. He will send you all the information you need. Thank you! Sincerely, Mrs. Cloudy. ~/Closed-Lab-4-rseld$
What is the Professor's Name? Robert
What is your last name? James
What is the illness: Cat Fever
Enter a plural noun: sashes
Enter a random word: Grape
Enter a random adjective: poor
Enter another random adjective: Murky
Enter another random word: Flash
Enter a random place in the world: Somalia
Enter a random whole number: 2
Enter a temperature value: 45.345
Enter a third random adjective: Cloudy
Dear Robert,
Grape James will not be attending school today.
He/she has come down with Cat Fever and has a poor case of the sashes.
Currently he/she has a 7.41 degrees Celsius fever.
We have made an appointment with the Murky Dr. Flash.
Dr. Flash has studied for many years in Somalia and has 6 degrees in medicine.
He will send you all the information you need. Thank you!
Sincerely,
Mrs. Cloudy
Transcribed Image Text:What is the Professor's Name? Robert What is your last name? James What is the illness: Cat Fever Enter a plural noun: sashes Enter a random word: Grape Enter a random adjective: poor Enter another random adjective: Murky Enter another random word: Flash Enter a random place in the world: Somalia Enter a random whole number: 2 Enter a temperature value: 45.345 Enter a third random adjective: Cloudy Dear Robert, Grape James will not be attending school today. He/she has come down with Cat Fever and has a poor case of the sashes. Currently he/she has a 7.41 degrees Celsius fever. We have made an appointment with the Murky Dr. Flash. Dr. Flash has studied for many years in Somalia and has 6 degrees in medicine. He will send you all the information you need. Thank you! Sincerely, Mrs. Cloudy
Expert Solution
Step 1

Find Your Answer Below

1. You have not read any value in your NumberTimes3 that's why by default it takes value 0. and shows NumberTimes3*3 = 0*3 = 0

put NumberTimes3 = 2 at line number 25 to resolve the issue.

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education