- 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); } } }

22nd Mar 2022, 12:37 AM
Learner
Learner - avatar
5 Respostas
+ 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
22nd Mar 2022, 12:58 AM
A͢J
A͢J - avatar
0
Blake Smith Lol I am telling you problem and you are saying your code is best instead of accepting mistake.
22nd Mar 2022, 1:02 AM
A͢J
A͢J - avatar
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());
22nd Mar 2022, 1:19 AM
A͢J
A͢J - avatar
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); } } }
22nd Mar 2022, 12:51 PM
Learner
Learner - avatar
- 4
My code is the best
22nd Mar 2022, 1:00 AM
Learner
Learner - avatar