Facebook
From Paltry Hummingbird, 2 Years ago, written in C#.
This paste is a reply to configuration.yaml from pawel - view diff
Embed
Download Paste or View Raw
Hits: 165
  1. using static System.Console;
  2. using System.Globalization;
  3. using System;
  4. //declare using "static" before system and ".Console" after system
  5.  
  6. namespace Lab3.Exercise._2_6
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.             //---- this is all input below ----
  12.         { //to have input you need to declare a variable
  13.             //double (variable name) + Declare it with a integer (optional)
  14.             const double BASE = 200;
  15.             const double PER_HOUR = 150; //constants are always caps'ed
  16.             const double PER_MILE = 2;
  17.  
  18.             double hours, miles, estimate;
  19.             Write("Enter the number of hours:");
  20.             // = does not equal like normal - in computer program anything on the right hand side will be store in the variable hours
  21.             // parenthesis is always executed first before the rest of the line.
  22.             hours = Convert.ToDouble(ReadLine());
  23.  
  24.             Write("How many miles is the move?:");
  25.             miles = Convert.ToDouble(ReadLine());
  26.  
  27.             //---- calculation ----
  28.             estimate = BASE + PER_HOUR * hours + PER_MILE * miles;
  29.  
  30.             //---- Output ----
  31.             //For a move taking 25 hours and going 55 miles the estimate is $4,060.00
  32.             //uses placeholders -> {0}
  33.             WriteLine("For a move taking {0} and going {1} miles", hours, miles);
  34.             WriteLine("the estimate is {0}", estimate.ToString("C", CultureInfo.GetCultureInfo("en-US")));
  35.  
  36.             //WriteLine("This is an example: {0}", estimate.ToString("C", CultureInfo.GetCultureInfo("en-US")));
  37.         }
  38.     }
  39. }
  40.