Level 1 - Inputs, outputs and structure 0 of 9 activities solved
  1. Hello World Not yet solved
  2. Carpet cost Not yet solved
  3. Ball pit Not yet solved
  4. Dice face 5 Not yet solved
  5. Temperature converter Not yet solved
  6. Fish tank volume Not yet solved
  7. Microscopy Not yet solved
  8. Circle properties Not yet solved
  9. Energy bill calculator Not yet solved
Next series Level 2 - Selections
Level 1 - Inputs, outputs and structure

Carpet cost

Sign in to hand in your solution and get feedback.

// Carpet cost program using System; class Submission { // ------------------------- // Subprograms // ------------------------- static double carpet_cost(int width, int length, double price) { double carpet = width * length * price; int grippers = width + length; int fitting = 50; return carpet + grippers + fitting; } // ------------------------- // Main program // ------------------------- public static void Main(string[] args) { Console.WriteLine("Enter the width of the room to nearest meter:"); int width = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the length of the room to nearest meter:"); int length = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the price of the carpet per m2:"); double price = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("The total cost is: £ " + carpet_cost(width, length, price)); } }