0
Hi guys just don't understand why it doesn't work the exercise 10.2 c#
I don't know how it works and firstly say input must be 800 and result 9600 and I'm the result says 1000 input and 12000 output. Sorry for ignorace Int salary = 1000; Salary *= 12; Or Int salary = 1000; Console.WriteLine(salary* 12); Or Int salary = 1000; Int months = 12; Console.WriteLine(salary* months);
26 Answers
+ 3
I think that maybe you are hard coding, only using those 2 numbers.
Isn't there an input?
Int salary = input;
Console.WriteLine(salary *12);
+ 2
Usually if you provide your attempt along with the question someone will come to your aid.
https://www.sololearn.com/Discuss/2881112/?ref=app
+ 2
That's right, look at the solution and look at your attempt. Do you notice the difference?
+ 1
You see how there's,
"Convert.ToInt32(Console.ReadLine());"?
That's an input. You need to remove your 1000 and put this input there. See if that works.
+ 1
If you add 1,000, then you can only solve 1 case: the case where the input is 1,000. You need to accept all inputs to solve all possible cases.
Try:
int monthlySalary = Convert.ToInt32(Console.ReadLine());
//check caps here
Console.WriteLine(monthlySalary *12);
No 1,000, no 800.
+ 1
Yo intento en español porque a mí me gusta la idioma ;)
Tú no toques el código que está arriba "//tu código va aqui". Eso es "input".
Tú solo tienes que escribir "Console.WriteLine(salary *12);" después.
O tu lo puedes hacer como:
salary *= 12;
"Console.WriteLine(salary);"
In English, because I imagine your English is better than my Spanish (but I love to practise).
The course has some code already written and this shouldn't be touched. In this example, it's the input you need. You only need to do the math of multiplying by 12.
The Tasks with ticks can give you the wrong idea sometimes. I think they are there so you can figure out "the logic" of what they want, which you have, you need "n" x 12. You need to then code this "n x 12".
Hopefully either of my 2 solutions work.
+ 1
Oh Thank you very much but I don't understand why in the written code they open 3 curly brackets and close 6 curly brackets, maybe is a error
I did some unity scripts before and I know a bit how to read Sintaxerrors or expected symbols but this one was very simple but difficult for me to understand. Again thanks all
+ 1
Did you figure it out?
+ 1
Yes
+ 1
Awesome how did you solve it?
+ 1
I'm actually working through the C# course to get to the assignment. My C# is very rusty. It has been a few years. So this a good refresher.
+ 1
I did what Ausgrindtube says. Didn't modify the code already existing and under it writed this: Console.WriteLine(salary *= 12);
Console.WriteLine();
And you have to remove 3 closed curly brackets if you have 6 and 3 opened
+ 1
I have arrived at the 10.2 To my surprise there are only 3 curly braces for me and I used the code that I shared earlier. And I passed all cases...
int annualSalary = 12;
Console.WriteLine(salary *= annualSalary);
+ 1
Our answers are similar however I declared a variable and assigned it the value 12.
+ 1
Ranjith Gunawardana don't spam
+ 1
Kumar Rai Is Solve but thank you for trying to help
0
TRIED LIKE THIS AND DOESNT WORK
I THINK I'M GONNA LEAVE PROGRAMING
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 monthlySalary = 1000;
int annualSalary = 12; Convert.ToInt32(Console.ReadLine());
Console WriteLine(monthlySalary * annualSalary )
}
}
}
0
You mean like this?
I tried and doesn't work...
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 monthlySalary
int annualSalary = 12; Convert.ToInt32(Console.ReadLine(1000));
Console WriteLine(monthlySalary * annualSalary );
}
}
}
0
When I use see a solution button it says to use this:
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)
{
decimal monthSalary =
int.Parse(Console.ReadLine());
Console.WriteLine(monthSalary *12);
}
}
}
0
I tried like the solution but nothing works by adding int.Parse(Console.ReadLine(1000))