+ 1

C# lesson 14

Hi everyone, I'm doing the practice for lesson 14 I'm doing exactly the lesson said but still can't run So would you guy help me to check if anything wrong with my coding Thank you

26th Sep 2021, 12:32 PM
Tim Tam
17 ответов
+ 3
Tim Tam You didn't assign input to variable num Also break is missing in 3rd case
26th Sep 2021, 12:36 PM
A͢J
A͢J - avatar
+ 2
Tim Tam int num = Convert.ToInt32(Console.ReadLine());
26th Sep 2021, 12:40 PM
A͢J
A͢J - avatar
+ 2
Tim Tam You have written complete code and still didn't get how to take input? You need to go through lesson again and check my previous reply. Just copy that line and put in your code
26th Sep 2021, 12:46 PM
A͢J
A͢J - avatar
+ 1
num is what you take as input, it is not a fixed value
26th Sep 2021, 12:42 PM
Lisa
Lisa - avatar
+ 1
Nakul Pasi S/O KrishnaLal Pasi This does not seem to be related to the thread's topic. Your code looks like some cpp. If you have a problem with your code, please create a new thread to get help
27th Sep 2021, 6:45 AM
Lisa
Lisa - avatar
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int num = 1; Convert.ToInt32(Console.ReadLine()); /* 1 - Sports 2 - Politics 3 - Business 4 - Technology 5 - Art */ //your code goes here switch(num) { case 1: Console.WriteLine("Sports"); break; case 2: Console.WriteLine("Politics"); break; case 3: Console.WriteLine("Business"); case 4: Console.WriteLine("Technology"); break; case 5: Console.WriteLine("Art"); break; } } } }
26th Sep 2021, 12:33 PM
Tim Tam
0
Oh thank you so much but how to input to variable number AJ
26th Sep 2021, 12:39 PM
Tim Tam
0
Iam so stupid, I still don't get it AJ
26th Sep 2021, 12:43 PM
Tim Tam
0
Yes I put Int num = 3; So it is not how to input the variable right?
26th Sep 2021, 12:46 PM
Tim Tam
0
num is not 3 as in your code, num is what Convert.ToInt32... You need to save this input in num
26th Sep 2021, 12:46 PM
Lisa
Lisa - avatar
0
num is user input, its value depends on what the users inputs as number – that's what is Console.ReadLine for
26th Sep 2021, 12:48 PM
Lisa
Lisa - avatar
0
Sorry guys I have the problem in the lesson 5, so I will learn again Thank you so much guys
26th Sep 2021, 12:49 PM
Tim Tam
0
Hi guy I really don't understand the lesson 5 I can't input the age for this
26th Sep 2021, 1:05 PM
Tim Tam
0
You just run the code, a input window opens, you type a number, submit and check the output
26th Sep 2021, 1:08 PM
Lisa
Lisa - avatar
0
Oh thank you so much Lisa
26th Sep 2021, 1:09 PM
Tim Tam