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
What is the by stander effect
nignag [31]

Answer:

The bystander effect is a theory that people are less likely to help if there are others around.

hope this helped :D

4 0
3 years ago
PLEASE HELP! I'm offering brainliest!
Marina CMI [18]

Answer:

1. Undo  2. Font Type   3. Font Size  4. Bold Font 5. <em>Italics  </em>6. Word Color  7.  Document Margins

Explanation:

Did you know that all of these answers are how to format a document?

7 0
3 years ago
_____ should be used to create a project schedule.
dem82 [27]

Answer:

meeting is the correct answer

3 0
3 years ago
Q#3. What are the advantages and disadvantages of Analog and Digital computers?​
Pie

Answer:

Advantages of Analog computers:

  • Many data parameters can be obtained concurrently in a simultaneous and real-time procedure.
  • Certain operations can be computed without the need of converters to transform the inputs and outputs to and from digital digital mode.
  • The developer must scale the problem for the computer's dynamic range during configuration. This might provide insight into the issue as well as the consequences of numerous faults.

Disadvantages of Analog computers:

  • Computer systems can handle greater issues for a certain efficiency and power usage.
  • Solution arise in real or delayed time, and recording them for subsequent use or investigation might be problematic.
  • The number of temporal variables that can be used is restricted. It's tough to correctly solve problems with elements that operate on radically various time periods.

Advantages of Digital computers:

  • It is a lot more efficient and more effective, particularly with today's computers, which can analyze information at a billion times the rate of a human.
  • Modern digital computers' incredible speed enables them to recreate objects in real time, resulting in new experiential characteristics of digital computers, such as interactive media.
  • It has the ability to convey information in a very brief manner. This enables data storage and transmission to be more efficient as digital systems are extremely dependable and controllable.

Disadvantages of Digital computers:

  • To complete the same tasks, digital computers need more power than analog computers, resulting in greater heat, which increases the complexity of the computer and necessitates the usage of heating elements.
  • To convey the same amount of data, digital computers require more capacity than analogue computers.
  • The detection of digital computers necessitates synchronization of the computer system, which is not always the scenario with analogue computers

5 0
2 years ago
Write a program that reads the subtotal and the gratuity rate, then computes the gratuity and total.For example, if the user ent
lubasha [3.4K]

Answer:

Using Javascript,

function calTotal( subtotal, gratuity){

  gratuityValue = subtotal * (gratuity/100)

  total = subtotal + gratuityValue

  console.log( "gratuity: ", gratuityValue , "\nTotal: ", total)

}

Explanation:

The javascript function above is able to collect two parameters subtotal and gratuity rate in percentage and calculate the total and gratuity value, and displays it on the console.

8 0
3 years ago
Other questions:
  • Designing the moving parts of a car—including the engine, drivetrain, steering, and brakes—is done by what type of engineer?
    11·2 answers
  • The responsibilities of the IT department and the needs of the user departments may cause conflicts over A. the color of the use
    6·1 answer
  • People are able to predict future events to some extent because: (Select all that apply)
    11·1 answer
  • What is a secondary storage medium that uses magnetic techniques to store and retrieve data on disks or tapes coated with magnet
    6·1 answer
  • What is the correct html element for playing audio files?
    11·1 answer
  • "The ______ of an operational system that supports an organization includes policies, requirements, and conditional statements t
    13·1 answer
  • News writers get story leads from____.
    8·1 answer
  • Anyone wanna hop on 1v1.lol<br> party code : usfhb6
    12·2 answers
  • The main technology for setting up a wireless local area network is​
    13·1 answer
  • ‘’AZ’’ is an example of a __.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!