{solved} C# 9.2 practice: parquet for living room | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

{solved} C# 9.2 practice: parquet for living room

Task: find out the size of the living room in square meters (decimal). My solution was the following: static void Main(string[] args) { //sides of the room double length; double width; length = 5.4; Convert.ToDouble(Console.ReadLine()); width = 2.3; Convert.ToDouble(Console.ReadLine()); //output the area double size = length * width; Console.WriteLine(size); Output: 12.42 So far, so correct. Yet in this practice there are 4 more tasks to complete, which i dont now how to complete within one code/answer. So i cant successfully complete the practice though the first task was correct... Thats unsatisfying. I am only able to fulfill one task at a time. That way i wont receive the xp... I want all of the tasks in the result screen marked with a green tick, not just one. But i dont know how to do it. Any advice for that? Thx :)

29th Aug 2021, 7:02 PM
FromAlex TotheAnder
FromAlex TotheAnder - avatar
9 Answers
+ 5
FromAlex TotheAnder, You need to confirm user input so that this program can perform all cases. Like: length = Convert.ToDouble(Console.ReadLine()); width = Convert.ToDouble(Console.ReadLine()); this will convert user input from string to double and store them in length and width variable respectively. After that you can write: double area = length * width; Console.WriteLine(area); Well thats it. Hope this helps. Actually I solved it in this way: static void Main(string[] args) { //sides of the room double length; double width; length = Convert.ToDouble(Console.ReadLine()); width = Convert.ToDouble(Console.ReadLine()); //output the area double area = length * width ; Console.WriteLine(area); }
30th Aug 2021, 3:59 AM
Monika Bairagi
Monika Bairagi - avatar
+ 6
FromAlex TotheAnder , to get useful help from the community,  we need to see your attempt first. without having seen your code, it is difficult to find out where the issue is. => please put your code in playground and link it here => please also provide a complete task description thanks! thanks!
29th Aug 2021, 7:35 PM
Lothar
Lothar - avatar
+ 3
FromAlex TotheAnder, your code worked only for the given length =5.4 and width=2.3 That's why only one test case passed. This code has to be working for all given inputs..for that instead of assigning values to length and width directly, assign the inputs to length and width. Thnx
29th Aug 2021, 9:18 PM
Jewel
Jewel - avatar
+ 3
FromAlex TotheAnder, length=Convert.ToDouble(Console.ReadLine()); width=Convert.ToDouble(Console.ReadLine()); This is how we assign it :) Convert.ToDouble(Console.ReadLine()) ; will ask for user input from keyboard and will convert the entered string to double. In your code the inputs are not stored anywhere.Always remember to assign inputs to some variable.
30th Aug 2021, 2:12 AM
Jewel
Jewel - avatar
+ 2
I don't have access to the practice so I can't really help you with anything, care to share your attempt first?
29th Aug 2021, 7:09 PM
Tim
Tim - avatar
+ 2
Thx Jewel ! Can you give me an example? How can i assign the inputs to the variables "length" and "width"? I just recognized that this issue will occure on the upcomming practices as well... i basically understand the task/issue but i wont get the tasks done at one time.
29th Aug 2021, 9:46 PM
FromAlex TotheAnder
FromAlex TotheAnder - avatar
+ 1
Just updatet the description. I hope that helps. Thx! By the way; does anybody know why there some tasks are "hidden" and not visible? In this practice eg. task 4 and 5.
29th Aug 2021, 8:47 PM
FromAlex TotheAnder
FromAlex TotheAnder - avatar
+ 1
Thx to Jewel and Monika Monika Bairagi You both rock!
30th Aug 2021, 8:49 AM
FromAlex TotheAnder
FromAlex TotheAnder - avatar
+ 1
FromAlex TotheAnder you're welcome😊
30th Aug 2021, 8:54 AM
Jewel
Jewel - avatar