Guest User

Untitled

a guest
Apr 27th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.73 KB | None | 0 0
  1. using Microsoft.VisualBasic;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Diagnostics;
  7. using System.Text.RegularExpressions;
  8.  
  9. static class Module1
  10. {
  11.  
  12.     public static void Main()
  13.     {
  14.         Console.WriteLine("Rectangular single-room carpeting jobs price quote");
  15.         string input = null;
  16.         int roomLength = findRoomLength();
  17.         int roomWidth = findRoomWidth();
  18.         int price = findPricePerYard();
  19.         double squareYardage = findSquareYardage(roomLength, roomWidth);
  20.         double materialcost = findMaterialCost(squareYardage, price);
  21.         double totalcost = 0;
  22.         do {
  23.             Console.WriteLine("Room Length = " + roomLength);
  24.             Console.WriteLine("Room Width = " + roomWidth);
  25.             Console.WriteLine("Price per square yard = $" + price);
  26.             Console.WriteLine("Square Yardage of room = " + squareYardage);
  27.             Console.WriteLine("Material cost = $" + materialcost);
  28.             if (((materialcost) < 800)) {
  29.                 Console.WriteLine("Installation cost = $200");
  30.                 totalcost = 200 + materialcost;
  31.             } else {
  32.                 Console.WriteLine("Installation cost is free because material cost exceeded $800");
  33.                 totalcost = materialcost;
  34.             }
  35.             Console.WriteLine("Total cost = $" + totalcost);
  36.             input = Console.ReadLine();
  37.         } while (true);
  38.         Console.WriteLine("Quitting now.");
  39.     }
  40.     private static int findRoomLength()
  41.     {
  42.         string input = null;
  43.         do {
  44.             Console.WriteLine("Please enter room length in ft");
  45.             input = Console.ReadLine();
  46.             if ((onlyNumbers(input) == false)) {
  47.                 Console.WriteLine("Input only numbers");
  48.  
  49.             }
  50.         } while ((onlyNumbers(input) == false & input.Length > 0));
  51.         return input;
  52.     }
  53.     private static int findRoomWidth()
  54.     {
  55.         string input = null;
  56.         do {
  57.             Console.WriteLine("Please enter room width in ft");
  58.             input = Console.ReadLine();
  59.             if ((onlyNumbers(input) == false)) {
  60.                 Console.WriteLine("Input only numbers");
  61.  
  62.             }
  63.         } while ((onlyNumbers(input) == false & input.Length > 0));
  64.         return input;
  65.     }
  66.     private static int findPricePerYard()
  67.     {
  68.         string input = null;
  69.         do {
  70.             Console.WriteLine("Please enter the price of the carpeting material on a per-square-yard basis");
  71.             input = Console.ReadLine();
  72.             if ((onlyNumbers(input) == false)) {
  73.                 Console.WriteLine("Input only numbers");
  74.  
  75.             }
  76.         } while ((onlyNumbers(input) == false & input.Length > 0));
  77.         return input;
  78.     }
  79.     private static bool onlyNumbers(string str)
  80.     {
  81.         return str.All(char.IsNumber);
  82.     }
  83.     private static double findSquareYardage(int length, int width)
  84.     {
  85.         double yardLength = length / 3;
  86.         double yardWidth = width / 3;
  87.         return yardLength * yardWidth;
  88.     }
  89.     private static double findMaterialCost(double squareyards, int pricePerYard)
  90.     {
  91.         return pricePerYard * squareyards;
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment