35 Replies
I don't understand what is wrong here
please dont post screenshots of code. $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/using System;
using System.ComponentModel.Design;
using System.Net.Security;
namespace Program
{
class Program
{
static void Main()
{
System.Console.Write("Введите число:" );
short x = Convert.ToInt16(Console.ReadLine());
System.Console.Write("Умножить или разделить или прибавить или уменьшить?:"); string bebra = Console.ReadLine() ; if ( bebra == "1") { System.Console.Write("Выбери число:"); short d = Convert.ToInt16(Console.ReadLine()); Console.Write("Ответ:" + (x * d));
} if ( bebra == "2") { System.Console.Write("Выберите число.:"); short e = Convert.ToInt16(Console.ReadLine()); Console.Write("Ответ:" + (x / e)); if ( bebra == "3") { System.Console.Write("Напиши число.:"); int f = Convert.ToInt32(Console.ReadLine()); Console.Write("Ответ:" + (x + f)); if ( bebra =="4") { System.Console.Write("Число дай:"); int g = Convert.ToInt32(Console.ReadLine()); Console.Write("Ответ:", x - g); } } }
} }
}
System.Console.Write("Умножить или разделить или прибавить или уменьшить?:"); string bebra = Console.ReadLine() ; if ( bebra == "1") { System.Console.Write("Выбери число:"); short d = Convert.ToInt16(Console.ReadLine()); Console.Write("Ответ:" + (x * d));
} if ( bebra == "2") { System.Console.Write("Выберите число.:"); short e = Convert.ToInt16(Console.ReadLine()); Console.Write("Ответ:" + (x / e)); if ( bebra == "3") { System.Console.Write("Напиши число.:"); int f = Convert.ToInt32(Console.ReadLine()); Console.Write("Ответ:" + (x + f)); if ( bebra =="4") { System.Console.Write("Число дай:"); int g = Convert.ToInt32(Console.ReadLine()); Console.Write("Ответ:", x - g); } } }
} }
}
Read the instructions again
You missed the important part
That's what I wrote, because I don't understand what's wrong here
$codegif
I don't spell it that way
this is your code, formatted
can you see the error?
no
Really?
what's the issue anyway? what are u complaining about?
I'll give you a hint, look at where your
bebra == 3
and bebra == 4
if statements are locatedeverything seems to be the same
what do you mean by that?
I don't see the error. They seem to be the same
Look at the lines for bebra 1 and 2, then compare to 3 and 4
Do you really not see a difference?
Really
this is a very stupid mistake
Thank you
Did you figure it out?
I'm confused
Yes. Thank you, I've been on the Internet for half an hour to figure out what the error is
Good. If and else isn't really the best choice here
A
switch
would be betterI know. I watch the course and study
Okay.
and is it possible to somehow make the cat, after its completion, start again?
yes, use a loop
is there an example?
when you want to stop the loop, type
break;
should I write this at the beginning of the line or at the end?
?
break
goes on its own line
its a line of its ownand what should I write at the end to start with a new line
I don't understand what your are asking to be honest
Okay.Thank you
I suggest formatting your code correctly. The way you have it right now is very difficult to read and understand.
To quickly format your code use the following shortcut: Ctrl K, D.
This means that you hold Ctrl, press and release K and while still holding Ctrl press D. After that release Ctrl.
Советую правильно форматировать код. То что в скриншоте трудно прочитать и тем более понять. Для быстрой отформатировки кода можно использовать сокращение Ctrl K, D. Это значит что держа Ctrl нужно нажать и отпустить К, а потом (ещё держа Ctrl) нажать D. После этого можно отпустить и Ctrl.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.