/ create the following functions: GetInteger - returns an integer DONE GetDouble - returns a double CheckInteger (called from GetInteger) - checks the range of an integer CheckDouble(called from GetDouble) - checks the range of a doubleCalculateSum - overloaded for integers and doubles as parameters DONE CalculateProduct - overloaded for integers and doubles as parameters DONE ShowSums - shows the sums of integers and the sum of doubles ShowProducts - shows the products of integers and the product of doubles. if you can create a function ShowInstructions that passes the type (integer or double) as a string. ShowInstructionsIntegers and ShowInstructionsDoubles

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter2: Basic Elements Of C++
Section: Chapter Questions
Problem 24SA
icon
Related questions
Question
/ create the following functions: GetInteger - returns an integer DONE GetDouble - returns a double CheckInteger (called from GetInteger) - checks the range of an integer CheckDouble(called from GetDouble) - checks the range of a doubleCalculateSum - overloaded for integers and doubles as parameters DONE CalculateProduct - overloaded for integers and doubles as parameters DONE ShowSums - shows the sums of integers and the sum of doubles ShowProducts - shows the products of integers and the product of doubles. if you can create a function ShowInstructions that passes the type (integer or double) as a string. ShowInstructionsIntegers and ShowInstructionsDoubles
cout « "Please enter a number between 1 and 10" c endl;
cout « "Number: ";
cin >» int3;
38
39
40
41
42
// Get three doubles.
cout « "Enter three doudbles between 1 and 10.";
cout « "\nIf you give doubles outside that range,;
cout « "\nyou will be asked again ";
cout « "\nuntil you give a valid number." « endl;
43
44
45
46
47
48
cout « "\nDouble 1: ";
cin >» doublel;
while (doublel <1 || doublel > 10)
49
50
51
52
cout « "Please enter a double between 1 and 10" « endl;
cout « "Double: ";
cin » doublei;
53
54
55
56
cout « "\nDouble 2: ";
cin >» double2;
while (double2 <1 || double2 > 1e)
{
cout « "Please enter a number between 1 and 10" « endl;
cout « "Double: ";
cin » double2;
57
58
59
60
61
62
63
64
cout « "\nDouble 3: ";
cin » double3;
while (doubles <a || doubles > 1e)
65
66
67
68
cout « "Please enter a number between 1 and 1e" « endl;
cout « "Double: ";
cin » double3;
69
70
71
72
73
I/ calculate the sum and product of integers
intSum - inti + int2 + int3;
intProduct - inti • int2 • int3;
74
75
76
77
// calculate the sum and product of doubles
doubleSum - doublel + double2 + doubles;
doubleProduct - doublei • double2 • double3;
I
78
79
80
%3D
81
82
//display to the user
cout « "\nThe sum of the integers is " « intsum « endl;
cout « "\nThe sum of the doubles is " « doublesum « endl;
83
84
85
86
cout « "The product of the integers is
cout « "The product of the doubles is" « doubleProduct « endl;
« intProduct « endl;
87
88
89
return e;
90
Transcribed Image Text:cout « "Please enter a number between 1 and 10" c endl; cout « "Number: "; cin >» int3; 38 39 40 41 42 // Get three doubles. cout « "Enter three doudbles between 1 and 10."; cout « "\nIf you give doubles outside that range,; cout « "\nyou will be asked again "; cout « "\nuntil you give a valid number." « endl; 43 44 45 46 47 48 cout « "\nDouble 1: "; cin >» doublel; while (doublel <1 || doublel > 10) 49 50 51 52 cout « "Please enter a double between 1 and 10" « endl; cout « "Double: "; cin » doublei; 53 54 55 56 cout « "\nDouble 2: "; cin >» double2; while (double2 <1 || double2 > 1e) { cout « "Please enter a number between 1 and 10" « endl; cout « "Double: "; cin » double2; 57 58 59 60 61 62 63 64 cout « "\nDouble 3: "; cin » double3; while (doubles <a || doubles > 1e) 65 66 67 68 cout « "Please enter a number between 1 and 1e" « endl; cout « "Double: "; cin » double3; 69 70 71 72 73 I/ calculate the sum and product of integers intSum - inti + int2 + int3; intProduct - inti • int2 • int3; 74 75 76 77 // calculate the sum and product of doubles doubleSum - doublel + double2 + doubles; doubleProduct - doublei • double2 • double3; I 78 79 80 %3D 81 82 //display to the user cout « "\nThe sum of the integers is " « intsum « endl; cout « "\nThe sum of the doubles is " « doublesum « endl; 83 84 85 86 cout « "The product of the integers is cout « "The product of the doubles is" « doubleProduct « endl; « intProduct « endl; 87 88 89 return e; 90
1#include <iostream>
2 using namespace std;
3
int main()
int inti, int2, int3, intsum, intProduct;
double doublei, double2, double3, doublesum, doubleProduct;
// Get three integers.
cout ce "Enter three integers between 1 and 10.";
cout « "\nIf you give numbers outside that range, ";
cout « "\nyou will be asked again ";
cout « "\nuntil you give a valid number." « endl;
10
11
12
13
14
15
cout « "\nNumber 1: ";
cin >» inti;
while (inti <1 || inti > 10)
16
17
18
19
cout « "Please enter a number between 1 and 10" « endl;
cout « "Number: ";
cin >» inti;
20
21
22
23
24
cout « "\nNumber 2: ";
cin >> int2;
while (int2 <1 || int2 > 10)
25
26
27
28
cout « "Please enter a number between 1 and 18" « endl;
cout « "Number: ";
cin » int2;
29
30
31
32
33
cout « "\nNumber 3: ";
cin >> int3;
while (int3 <1 || int3 > 10)
34
35
36
37
38
cout « "Please enter a number between 1 and 10" « endl;
cout « "Number: ";
cin » int3;
39
40
41
42
// Get three doubles.
cout « "Enter three doudbles between 1 and 10.";
cout « "\nIf you give doubles outside that range, ";
cout « "\nyou will be asked again ";
cout « "\nuntil you give a valid number." <« endl;
43
44
45
46
I
47
cout « "\nDouble 1: ";
cin » doublel;
while (double1 <1 || double1 > 10)
49
51
52
53
cout <« "Please entera double between 1 and 10" <« endl;
Transcribed Image Text:1#include <iostream> 2 using namespace std; 3 int main() int inti, int2, int3, intsum, intProduct; double doublei, double2, double3, doublesum, doubleProduct; // Get three integers. cout ce "Enter three integers between 1 and 10."; cout « "\nIf you give numbers outside that range, "; cout « "\nyou will be asked again "; cout « "\nuntil you give a valid number." « endl; 10 11 12 13 14 15 cout « "\nNumber 1: "; cin >» inti; while (inti <1 || inti > 10) 16 17 18 19 cout « "Please enter a number between 1 and 10" « endl; cout « "Number: "; cin >» inti; 20 21 22 23 24 cout « "\nNumber 2: "; cin >> int2; while (int2 <1 || int2 > 10) 25 26 27 28 cout « "Please enter a number between 1 and 18" « endl; cout « "Number: "; cin » int2; 29 30 31 32 33 cout « "\nNumber 3: "; cin >> int3; while (int3 <1 || int3 > 10) 34 35 36 37 38 cout « "Please enter a number between 1 and 10" « endl; cout « "Number: "; cin » int3; 39 40 41 42 // Get three doubles. cout « "Enter three doudbles between 1 and 10."; cout « "\nIf you give doubles outside that range, "; cout « "\nyou will be asked again "; cout « "\nuntil you give a valid number." <« endl; 43 44 45 46 I 47 cout « "\nDouble 1: "; cin » doublel; while (double1 <1 || double1 > 10) 49 51 52 53 cout <« "Please entera double between 1 and 10" <« endl;
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Variables
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr