- 3
My accurate floating point arithmetic (length*width=area) program code (gives errors):
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { //sides of the room double length = (5.4),(2.5); int length = 3; length = '(5.4),(2.5),(3)'; Convert.ToDouble(Console.ReadLine(length); double width = (2.3),(2.5); width = '(2.3),(2.5),(4)'; int width = 4; Convert.ToDouble(Console.ReadLine(width); //output the area Console.Write(length*width); } } }
5 Réponses
+ 2
Blake Smith
You have many mistakes.
Variable can't have comma separated values so
double length = 5.4, 2.5 is wrong
Others are also same.
Take user input, don't write Hard Code value
Convert.ToDouble(Console.ReadLine()); should be assign to a variable.
You need to review lesson again
0
Blake Smith
Lol I am telling you problem and you are saying your code is best instead of accepting mistake.
0
Blake Smith
As I said don't write Hard Code value and Convert.ToDouble should be assign to a variable so your inputs should be:
length = Convert.ToDouble(Console.ReadLine());
width = Convert.ToDouble(Console.ReadLine());
0
I recently finished all the test cases individually. The code below worked. For some reason it has not passed me to the next lesson.... 🙂
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
//sides of the room
double length;
double width;
length = 2.5; Convert.ToDouble(Console.ReadLine());
width = 2.5; Convert.ToDouble(Console.ReadLine());
//output the area
Console.Write(length*width);
}
}
}
- 4
My code is the best