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
scZoUnD [109]
3 years ago
14

Write a C# program named InchesToCentimeters that declares a named constant that holds the number of centimeters in an inch: 2.5

4. Also declare a variable to represent a measurement in inches, and assign a value. Display the measurement in both inches and centimeters—for example, if inches is set to 3, the output should be: 3 inches is 7.62 centimeters. Note: For final submission, set the number of inches equal to 3.
Computers and Technology
1 answer:
Over [174]3 years ago
5 0

Answer:

The C# program for the scenario is given below.

using System;

class InchesToCentimeters

{

   static void Main() {

       // const is used to declare constant variable of any data type

       const double CentimeterInInch = 2.54;

       double inch = 3;

       double centimeter;

       centimeter = inch*CentimeterInInch;

       Console.WriteLine( inch + " inches is " + centimeter + " centimeters." );

   }

}

OUTPUT

3 inches is 7.62 centimeters.

Explanation:

The program is named InchesToCentimeters. As per the question, this program converts inches into centimeters.

The program is not designed to take any user input. All the variables are assigned values inside the program itself. Hence, no validation is implemented.

All the variables are declared as double as per the conversion factor, 2.54, mentioned in the question.

1. As mentioned, a constant double variable is declared and initialized. The variable is declared using keyword, const. This keyword instructs the compiler that the value of variable will not change. Any variable declared with const keyword is also initialized simultaneously.

2. This variable holds the number of centimeters present in one inch.

const double CentimeterInInch = 2.54;

3. Next, a double variable is declared to hold value of inches to be converted.

double inch = 3;

4. Another double variable is declared to hold value of centimeters.

double centimeter;

5. The value assigned to the variable, centimetre, is computed using the previously declared variables.

centimeter = inch*CentimeterInInch;

6. Lastly, the value of inches and the corresponding value of centimeters is displayed on the output.

Console.WriteLine( inch + " inches is " + centimeter + " centimeters." );

7. The function, Console.WriteLine, inserts a new line at the end after the message is displayed.

8. Another function, Console.Write, can also be used to display the message. This function does not inserts a new line at the end after the message is displayed.

C# is a purely object-oriented programming language and hence, all the code is written inside the class.

The program can be tested for positive double values for inches.

You might be interested in
You are trying to determine why a packet of data is not being correctly sent over the internet. You determine that the problem i
spayn [35]
Answer is A it has a false ip so that is why an error is happening therefore the answer would be A.
6 0
3 years ago
Read 2 more answers
how could environmental and energy problem Kenya faces as far computer installations are concerned be avoided​
ipn [44]

The environmental and energy problem Kenya faces as far computer installations are concerned can be avoided​ by

  • Knowing and finding out the key aspect of ICT strength.
  • Create an holistic judgements in the assessment of ICT capability. Promote the use of solar power.

<h3>How can we overcome ICT challenges?</h3>

There are a lot of Energy Challenges in terms of ICT  in Kenyan and it is good the government and the people work towards energy in terms of sustainable ICT.

Therefore, The environmental and energy problem Kenya faces as far computer installations are concerned can be avoided​ by

  • Knowing and finding out the key aspect of ICT strength.
  • Create an holistic judgements in the assessment of ICT capability. Promote the use of solar power.

Learn more about computer installations from

brainly.com/question/11430725

#SPJ1

7 0
2 years ago
Digital learning can help students who enjoy
mr Goodwill [35]

Answer:

flexibility and independence

Explanation:

6 0
3 years ago
What is data mining ​
Vesna [10]

Answer:

Data mining is a process of extracting and discovering patterns in large data sets involving methods at the intersection of machine learning, statistics, and database systems.

5 0
3 years ago
Read 2 more answers
Which activity is a case of identity theft
dezoksy [38]
<span>Criminal identity theft (posing as another person when apprehended for a crime)Financial identity theft (using another's identity to obtain credit, goods and services)Identity cloning (using another's information to assume his or her identity in daily life)Medical identity theft (using another's identity to obtain medical care or drugs)<span>Child identity theft]


cite: wikipedia</span></span>
4 0
3 years ago
Read 2 more answers
Other questions:
  • Describe the Software Development Life Cycle. Describe for each phase of the SDLC how it can be used to create software for an E
    14·1 answer
  • What is data security
    14·1 answer
  • Three uses for Auto Formatting in Word 2016.
    5·1 answer
  • You start up your laptop while getting a coffee across the room. You hear the usual chimes and doinks as it starts up. When you
    14·2 answers
  • Why is the lack of a sense of humor a serious limitation for AI?
    6·1 answer
  • JAVA
    5·1 answer
  • To communicate with coworkers in the office
    10·1 answer
  • A data center needs to ensure that data is not lost at the system level in the event of a blackout. Servers must stay operable f
    6·1 answer
  • Lily obtained data from five trails 50 kcal 72 kcal 12 kcal and 50 kcal which best decribes her data
    11·1 answer
  • 15. You read a news article that's politically biased and not well organized. It's
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!