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]
4 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]4 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
When compared to traditional desktop customers, why are mobile phone users much more likely to book a room or airline reservatio
Gnesinka [82]
With mobile phone you can access data/internet wherever reception/coverage whereas desktop users cannot
4 0
3 years ago
4. Ernesto works in a small office with five other people. What are two possible connection
PIT_PIT [208]

LAN is the networking device and channel that interconnects the local area systems. If the company uses LAN, then issues with speed and connectivity will occur.

<h3>What is LAN?</h3>

The local area network connects the computers of small and local regions confined to small geographical areas and is seen in the schools, offices, and residences.

If LAN is used between more people then the internet speed and connectivity will be affected as there will be redundancy in the data packet transfer speed.

Therefore, the speed and connectivity will be affected.

Learn more about LAN here:

brainly.com/question/14308916

#SPJ1

5 0
2 years ago
Apps are designed by___.
nadya68 [22]

Explanation:

Apps are designed by___.

A. Software Developer

is the answer

3 0
3 years ago
Read 2 more answers
In codd's model of a relational database, data is stored in a(n) _____, which maintains information about a(
Dmitry [639]
<span>Which is not a component of a database that describes how data is stored?</span>
5 0
4 years ago
Data_____is defined as the condition in which all of the data in the database are consistent with the real-world events and cond
mezya [45]

Answer:

d. integrity

Explanation:

Data integrity is defined as the condition in which all of the data in the database are consistent with the real-world events and conditions.

Data integrity can be used to describe a state, a process or a function – and is often used as a proxy for “data quality”. Data with “integrity” is said to have a complete or whole structure. Data integrity is imposed within a database when it is designed and is authenticated through the ongoing use of error checking and validation routines. As a simple example, to maintain data integrity numeric columns/cells should not accept alphabetic data.

4 0
4 years ago
Other questions:
  • In order to paint a wall that has a number of windows, we want to know its area. Each window has a size of 2 ft by 3 ft. Write a
    12·2 answers
  • Explain what the 35ppm specification means
    13·1 answer
  • Which of the following cannot be performed from the windows task manager?
    15·2 answers
  • Between Handshake protocol, change cipher suite, alert and appplication data protocols, the first one to use is:
    13·1 answer
  • Explain how to utilize the computer in rooms management.​
    13·1 answer
  • 3. State whether the given statements are true or false. a. The computer is called a data processor because it can store, proces
    13·1 answer
  • 19 dollar fortnite giftcard who wants it
    15·2 answers
  • Explain the following buttons as used in emails:compose,inbox and Draft.<br>​
    10·1 answer
  • New and just need help with C coding. I've tried if statements and it outputs the wrong number.
    6·2 answers
  • An opening inside the system unit in which you can install additional equipment can be known as
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!