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]
4 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]4 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
Which factor helps drive globalization?
Kipish [7]

Containerisation. The costs of ocean shipping have come down, due to containerisation, bulk shipping, and other efficiencies. ...

Technological change. ...

Economies of scale. ...

Differences in tax systems. ...

Less protectionism. ...

Growth Strategies of Transnational and Multinational Companies.

7 0
3 years ago
is defined as the condition in which all of the data in the database are consistent with the real-world events and conditions
-BARSIC- [3]

\boxed{Data \:anomaly} is defined as the condition in which all of the data in the database are consistent with the real-world events and conditions.

\red{\large\qquad \qquad \underline{ \pmb{{ \mathbb{ \maltese \: \: Mystique35}}}}}

3 0
3 years ago
A spreadsheet contains the maximum weight and maximum height for fifty dog breeds. The breeds are located in rows, and the weigh
MrRa [10]

Answer:

a. Locate

Explanation:

Question options (obtained on the net):

a. Locate

b. Sort

c. Filter

d. Replace

Explanation:

The largest value of the weights of the dog breed in row 43 is the maximum weight of the dog breed in the row

The 'MAX' formula or the 'Autosum' tool can be used to give the largest value in a row, or column

To locate the maximum value in MS Excel, the ADDRESS and MATCH and MAX functions are combined and entered into the blank cell on the right, specifying the same range for the MAX and MATCH functions, and a '0' for the MATCH function as well as a '1' for the ADDRESS function as follows;

=ADDRESS(MATCH(MAX(A1:E1), A1:E1, 0), 1)

Therefore, to navigate to the maximum weight, Emily should use a <em>locate</em>(ing) tool navigate to the information on the spread sheet

8 0
3 years ago
Suppose that a laptop identifies its processor as follows: AMD’s A84500M. What does the AMD represent?
zalisa [80]

Answer:

Advanced Micro Devices

Explanation:

4 0
3 years ago
What should a pie chart represent?
Crazy boy [7]

Answer:

Data that adds up to 100%

Explanation:

7 0
2 years ago
Other questions:
  • You are working the 8:00 AM shift at the help desk. An irate user who fails to identify himself calls in claiming that his works
    7·1 answer
  • Max needs to study more effectively to get a better grade on his next exam. What can he do to improve his study habits? Check al
    10·2 answers
  • Which AWS service is a managed service that makes it easy to set up, operate, and scale a relational database in the cloud?​
    9·1 answer
  • When you buy an Xbox 360 can you play online for free
    12·2 answers
  • Psychographics may also be called A. personality analytics. B. social group dynamics. C. lifestyle analysis. D. opinion insight.
    6·1 answer
  • Which views can be used to see appointments in Outlook 2016? Check all that apply. Today Tomorrow Next 7 Days Work Week Two Week
    13·1 answer
  • Every Java statement ends with: *<br><br> Period<br> Colon<br> Double quote<br> Semicolon
    11·2 answers
  • Explain why the computer is powerful working tool???​
    7·1 answer
  • Question is attached as image, please help :&gt;
    15·1 answer
  • In MS Word we can merga cells true or false​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!