1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Natali [406]
3 years ago
15

Write a program in C++ or C that includes two different enumeration types and has a significant number of operations using the e

numeration types. Also write the same program using only integer variables. Compare the readability and predict the reliability differences between the two programs.
Computers and Technology
1 answer:
CaHeK987 [17]3 years ago
3 0

Answer:

Enum is a value type data type which is used to declare a list of named integer constants and can be defined using the enum keyword inside a class, or structure. The enum is used to give a name to each constant so that the constant integer can be called using its name. In most case enum provides a better readability than showing some integer values.

Explanation:

Using enum:

#include<iostream>

#include<string>

#include<stdlib.h>

using namespace std;

enum TempLevel { Low = 15, Medium = 30, High = 45 };

enum TempConverter{ Celsius = 1, Fahrenheit };

void TempLevel(int convertedValue);

int main()

{

while (true)

{

TempConverter Converter;

int userInput, choice, convertedValue;

cout << "----------------------------------" << endl;

cout << "Please enter the choice : " << endl;

cout << "Enter " << Celsius << " -- convert from Celsius to Fahrenheit" << endl;

cout << "Enter " << Fahrenheit << " -- convert from Fahrenheit to Celsius" << endl;

cout << "Choice :";

cin >> choice;

switch (choice)

{

case Celsius:

cout << "Please enter the Celsius value : ";

cin >> userInput;

convertedValue = (userInput * 9 / 5) + 32;

cout << "Fahrenheit is " << convertedValue << endl;

TempLevel(userInput);

break;

case Fahrenheit:

cout << "Please enter the Fahrenheit value : ";

cin >> userInput;

convertedValue = (userInput - 32) * 5 / 9;

cout << "Celsius is " << convertedValue << endl;

TempLevel(convertedValue);

break;

default:

cout << "Invalid Option" << endl;

exit(0);

break;

}

}

}

void TempLevel(int convertedValue)

{

string result;

convertedValue <= Low ? result = "Temperature is cold" : "";

convertedValue > Low && convertedValue <= Medium ? result = "Temperature is comfort" : "";

convertedValue > Medium && convertedValue <= High ? result = "Temperature is hot" : "";

convertedValue > High ? result = "Temperature is very hot" : "";

cout << result << endl;

}

Using integer datatype:

#include <iostream>

#include<string>

#include<stdlib.h>

using namespace std;

void TempLevel(int convertedValue);

int main()

{

while (true)

{

int userInput, choice, convertedValue;

cout << "----------------------------------" << endl;

cout << "Please enter the choice : " << endl;

cout << "Enter 1 -- convert from Celsius to Fahrenheit" << endl;

cout << "Enter 2 -- convert from Fahrenheit to Celsius" << endl;

cout << "Choice :";

cin >> choice;

switch (choice)

{

case 1:

cout << "Please enter the Celsius value : ";

cin >> userInput;

convertedValue = (userInput * 9 / 5) + 32;

cout << "Fahrenheit is " << convertedValue << endl;

TempLevel(userInput);

break;

case 2:

cout << "Please enter the Fahrenheit value : ";

cin >> userInput;

convertedValue = (userInput - 32) * 5 / 9;

cout << "Celsius is " << convertedValue << endl;

TempLevel(convertedValue);

break;

default:

cout << "Invalid Option" << endl;

exit(0);

break;

}

}

}

void TempLevel(int convertedValue)

{

string result;

convertedValue <= 15 ? result = "Temperature is cold" : "";

convertedValue > 15 && convertedValue <= 30 ? result = "Temperature is comfort" : "";

convertedValue > 30 && convertedValue <= 45 ? result = "Temperature is hot" : "";

convertedValue > 45 ? result = "Temperature is very hot" : "";

cout << result << endl;

}

You might be interested in
25 points select 3 options!!!!!!!!!!!!!!!!!!!!!!!!!
Veronika [31]

Answer: don't know sorry

Explanation:

5 0
2 years ago
Read 2 more answers
Consider two different implementations, M1 and M2, of the same instruction set. There are three classes of instructions (A, B, a
Margaret [11]

Explanation:

A.)

we have two machines M1 and M2

cpi stands for clocks per instruction.

to get cpi for machine 1:

= we multiply frequencies with their corresponding M1 cycles and add everything up

50/100 x 1 = 0.5

20/100 x 2 = 0.4

30/100 x 3 = 0.9

CPI for M1 = 0.5 + 0.4 + 0.9 = 1.8

We find CPI for machine 2

we use the same formula we used for 1 above

50/100 x 2 = 1

20/100 x 3 = 0.6

30/100 x 4 = 1.2

CPI for m2 =  1 + 0.6 + 1.2 = 2.8

B.)

CPU execution time for m1 and m2

this is calculated by using the formula;

I * CPI/clock cycle time

execution time for A:

= I * 1.8/60X10⁶

= I x 30 nsec

execution time b:

I x 2.8/80x10⁶

= I x 35 nsec

6 0
2 years ago
Your mothers date of birth and a unique personal identification number (pin) code provide authentication by _____.
Semenov [28]
Hello <span>Madysonhenders2477 </span><span>

Answer: Your mothers date of birth and a unique personal identification number (pin) code provide authentication by What you are (C)

Since your identification is about who you are, this would be the answer.

Hope This Helps!
-Chris</span>
6 0
3 years ago
Pa help please I need help<br>10 points :'(<br>nonsense report:<br>1 heart​
tatuchka [14]

Answer:

√ 1. Cellphone

<h3>Product Description:</h3>

A cellphone is any portable telephone that uses cellular network technology to make and receive calls.

7 0
2 years ago
What is information richness?
mrs_skeptik [129]

d. Refers to the depth and breadth of details contained in a piece of textual, graphic, audio, or video information.

<h3>Information richness</h3>

Information richness refers to the amount of sensory input available during communication. For example, <u>talking to co-workers in a monotone voice without varying pace or gestures is not a very enriching experience</u>. On the other hand, using gestures, tone of voice, and pace of speech to convey meaning beyond the words themselves promotes richer communication. Different channels have different information wealth.

Information-rich channels convey more non-verbal information. For example, a face-to-face conversation is richer than a phone call, but a phone call is richer than an email. Research shows that effective managers are more likely to use informative channels of communication than ineffective managers.

Learn more about Note-making Information: brainly.com/question/1299137

#SPJ4

4 0
1 year ago
Other questions:
  • Suppose we wish to put a set of names in alphabetical order. We call the act of doing so sorting. One algorithm that can accompl
    15·1 answer
  • .How does kinetic energy affect the stopping distance of a vehicle traveling at 30 mph compared to the same vehicle traveling at
    13·1 answer
  • This is going to get taken down but I dont care add me on discord cause ima bored<br> -Red-#9847
    12·1 answer
  • #Write a function called string_finder. string_finder should #take two parameters: a target string and a search string. #The fun
    14·1 answer
  • High productivity will typically get you positive attention and feedback when you are on a job.
    7·1 answer
  • Instructions:Drag the tiles to the boxes to form correct pairs.
    11·2 answers
  • In symmetric key cryptosystem, assume that Alice and Bob have set up a common key Kab. This key is only known to Alice and Bob.
    12·1 answer
  • A ________ is a member function that is automatically called when a class object is
    6·1 answer
  • This computer is used by touching your finger.
    14·1 answer
  • Instructions: Write a program that calculates the amount of ingredients needed for various flavors of cheesecake.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!