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
Port Address Translation assigns non-routing local addresses to the computer systems in the local area network and uses ISP-assi
nadezda [96]

Answer:

The answer is "False"

Explanation:

It is an extension of domain controller conversion, which allows multiple computers to connect with internet addresses on some kind of LAN. PAT's goal is to keep the IP addresses.

  • NAT converts device IP addresses within the same LAN into a single Address. It connects the device to the Internet also uses this address.
  • It links the router to a DSL modem, cable modem, line T1 or even a dial-up modem, that's why this statement is false.
3 0
4 years ago
Claudia has a bachelors degree in computer information systems and she has learned to use some popular software testing tolls wh
mihalych1998 [28]
Coder
website analyser
website maker
poll reader
3 0
3 years ago
Read 2 more answers
In the organizational structure, the vendor management team is responsible for managing security concerns involving third partie
anygoal [31]

Answer:

True

Explanation:

The vendor management team are in charge of dealing with external party or vendors. The vendor management team is in charge of managing the vendor relationships. They perform a lot of duties to ensure the profitability of the partnership as long as their services are needed by the company. The vendor management team serves as the bridge between the company and the vendors.

6 0
3 years ago
Consider the following instruction: OR( %1111_0000, AL ) ; After its execution, what will be true about the bits stored in AL?
stiv31 [10]

Answer:

the higher order bits in AL will be true

Explanation:

We know from the truth table that in an OR operation, once one operand is true the result is true, no matter the value of the other operand. From the above AL will have the higher order bits to be true since the first four higher order bits are 1s, 1111_0000, this is regardless of the original values of AL. We cannot however ascertain if the lower bits of AL are true from this. Note 1 evaluates to true while 0 is false

6 0
3 years ago
Gerard is currently working as an entry-level customer support technician, but he would like to someday become a software develo
Ivahew [28]
Im going to say that the answer is c but i may be wrong..Hope i helped 
3 0
4 years ago
Other questions:
  • Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which princ
    8·1 answer
  • A(n) ____ is a location on your computer screen where you type text entries to communicate with the computer’s operating system.
    9·2 answers
  • Using the _______ list, you can select the number of photos that will appear on each slide.
    10·2 answers
  • Assume you have created a program that has the user enter an email address of the form: <a href="/cdn-cgi/l/email-protection" cl
    11·1 answer
  • Which is a good guideline to follow when looking for research material on the Internet?
    10·2 answers
  • Tell me dynamo is easily charge 12 v battery if dc motor is 100w in electric cycle?
    5·1 answer
  • "Rights and duties are two sides of the same coin." Explain with examples​
    5·1 answer
  • What is the bandwidth for asymmetric digital subscriber line<br> (ADSL)?
    10·2 answers
  • How can you create a messages to look like an IMessage?
    8·1 answer
  • when doing a complex presentation which of the fallowing will be the best tool to begin designing your presentation
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!