Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualBasic;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Text.RegularExpressions;
- static class Module1
- {
- public static void Main()
- {
- Console.WriteLine("Rectangular single-room carpeting jobs price quote");
- string input = null;
- int roomLength = findRoomLength();
- int roomWidth = findRoomWidth();
- int price = findPricePerYard();
- double squareYardage = findSquareYardage(roomLength, roomWidth);
- double materialcost = findMaterialCost(squareYardage, price);
- double totalcost = 0;
- do {
- Console.WriteLine("Room Length = " + roomLength);
- Console.WriteLine("Room Width = " + roomWidth);
- Console.WriteLine("Price per square yard = $" + price);
- Console.WriteLine("Square Yardage of room = " + squareYardage);
- Console.WriteLine("Material cost = $" + materialcost);
- if (((materialcost) < 800)) {
- Console.WriteLine("Installation cost = $200");
- totalcost = 200 + materialcost;
- } else {
- Console.WriteLine("Installation cost is free because material cost exceeded $800");
- totalcost = materialcost;
- }
- Console.WriteLine("Total cost = $" + totalcost);
- input = Console.ReadLine();
- } while (true);
- Console.WriteLine("Quitting now.");
- }
- private static int findRoomLength()
- {
- string input = null;
- do {
- Console.WriteLine("Please enter room length in ft");
- input = Console.ReadLine();
- if ((onlyNumbers(input) == false)) {
- Console.WriteLine("Input only numbers");
- }
- } while ((onlyNumbers(input) == false & input.Length > 0));
- return input;
- }
- private static int findRoomWidth()
- {
- string input = null;
- do {
- Console.WriteLine("Please enter room width in ft");
- input = Console.ReadLine();
- if ((onlyNumbers(input) == false)) {
- Console.WriteLine("Input only numbers");
- }
- } while ((onlyNumbers(input) == false & input.Length > 0));
- return input;
- }
- private static int findPricePerYard()
- {
- string input = null;
- do {
- Console.WriteLine("Please enter the price of the carpeting material on a per-square-yard basis");
- input = Console.ReadLine();
- if ((onlyNumbers(input) == false)) {
- Console.WriteLine("Input only numbers");
- }
- } while ((onlyNumbers(input) == false & input.Length > 0));
- return input;
- }
- private static bool onlyNumbers(string str)
- {
- return str.All(char.IsNumber);
- }
- private static double findSquareYardage(int length, int width)
- {
- double yardLength = length / 3;
- double yardWidth = width / 3;
- return yardLength * yardWidth;
- }
- private static double findMaterialCost(double squareyards, int pricePerYard)
- {
- return pricePerYard * squareyards;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment