public void MyCode() { // The FIRST line of code should be BELOW this line CubeCalculator cc = new CubeCalculator(); String userInput = cc.GetUserInput("Please enter an integer number:"); while (userInput != "q") { if (cc.IsANumber(userInput)) { int value = cc.ConvertToNumber(userInput); int result = cc.CalculateCube(value); Console.WriteLine("The cube of {0} is {1}", value, result); } else { Console.WriteLine("Could not calculate..."); } userInput = cc.GetUserInput("Press Q to quit or enter a number: "); } // The LAST line of code should be ABOVE this line }
public void MyCode() { // The FIRST line of code should be BELOW this line CubeCalculator cc = new CubeCalculator(); String userInput = cc.GetUserInput("Please enter an integer number between 1 and 10:"); while (Int32.Parse(userInput) <= 10 && Int32.Parse(userInput) >= 1) { if (cc.IsANumber(userInput)) { int value = cc.ConvertToNumber(userInput); int result = cc.CalculateCube(value); Console.WriteLine("The cube of {0} is {1}", value, result); userInput = cc.GetUserInput("Please enter an integer number between 1 and 10:"); } else { Console.WriteLine("Could not calculate..."); } } // The LAST line of code should be ABOVE this line }
public void MyCode() { // The FIRST line of code should be BELOW this line CubeCalculator cc = new CubeCalculator(); //opretter et nyt objekt String userInput = cc.GetUserInput("Please enter a number or type 'done' to quit: "); while (userInput != "done") { if (cc.IsANumber(userInput)) { int value = cc.ConvertToNumber(userInput); int result = cc.CalculateCube(value); Console.WriteLine($"The cube of {value} is {result}"); } else { Console.WriteLine("Could not calculate..."); } userInput = cc.GetUserInput("Please enter a number or type 'done' to quit "); } // The LAST line of code should be ABOVE this line }
public void MyCode() { // The FIRST line of code should be BELOW this line CubeCalculator cc = new CubeCalculator(); while (running) { String userInput = cc.GetUserInput("Please enter an integer number:"); if (cc.IsANumber(userInput)) { int value = cc.ConvertToNumber(userInput); int result = cc.CalculateCube(value); Console.WriteLine("The cube of {0} is {1}", value, result); } else { Console.WriteLine("Could not calculate..."); } } // The LAST line of code should be ABOVE this line }