Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Assignment1Part4
  7. {
  8.     class Program
  9.     {
  10.        
  11.         static string productName;
  12.         static double pounds,
  13.                       ounces,
  14.                       poundTok = 0.454f,
  15.                       ounceTok = 0.0283f,
  16.                       convertPounds,
  17.                       convertOunces,
  18.                       totalKiloWeight;
  19.  
  20.         static void Main(string[] args)
  21.         {
  22.             GetWeight();
  23.             Calculate();
  24.             Display();
  25.         }
  26.  
  27.         static void GetWeight()
  28.         {
  29.             Console.Write("Please Enter Name of Product: ");
  30.             productName = Console.ReadLine();
  31.  
  32.             Console.Write("\nPlease Enter Weight of Product (Pounds): ");
  33.             pounds = Convert.ToDouble(Console.ReadLine());
  34.  
  35.             Console.Write("\nPlease Enter Weight of Product (Ounces): ");
  36.             ounces = Convert.ToDouble(Console.ReadLine());
  37.  
  38.  
  39.         }
  40.  
  41.         static void Calculate()
  42.         {
  43.             convertPounds = pounds * poundTok;
  44.             convertOunces = ounces * ounceTok;
  45.             totalKiloWeight = convertPounds + convertOunces;
  46.         }
  47.  
  48.         static void Display()
  49.         {
  50.             Console.WriteLine("\nPounds converted to Kilograms: {0}lb", String.Format("{0:0.00}", poundTok));
  51.             Console.WriteLine("\nOunces converted to Kilograms: {0}oz", String.Format("{0:0.00}", ounceTok));
  52.             Console.WriteLine("\nTotal Weight in Kilograms: {0}kg", String.Format("{0:0.00}", totalKiloWeight));
  53.             Console.ReadKey();
  54.         }
  55.        
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement