Cheer creator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Cheer creator

What's wrong here? 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) { Convert.Tolnt32 (Console.RideLine()); int = yards; if yards < 1 { Console. Write ("shh"); } else if ( yards <=10 ) { for (int g = 1; g < yards; g++ ) { Console.Write ("Ra!"); } else if (yards > 10) { Console. Write ("High Five"); } } } }

21st Feb 2020, 6:46 PM
GAG98
GAG98 - avatar
11 Answers
0
Gleb When you type, Console.Readline() save your Enter button (or \n), thats not a valid character to convert by using Convert.ToInt32. You should use: int yards = int.Parse(Console.Readline())
21st Feb 2020, 8:15 PM
Trần Tân An Nguyễn
Trần Tân An Nguyễn - avatar
+ 3
how many RA! for three yards? (one too less)
21st Feb 2020, 6:51 PM
Oma Falk
Oma Falk - avatar
0
You should set int g=0 in for loop. Because loop stops when g<yards (which means g==yards-1, and it just loops (yards-1) times). This is not expected answer.
21st Feb 2020, 7:05 PM
Trần Tân An Nguyễn
Trần Tân An Nguyễn - avatar
0
Still a mistake, something with Convert.Tolnt32 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 yards=Convert.Tolnt32 (Console.ReadLine()); if (yards < 1) { Console. WriteLine ("shh"); } else if ( yards <=10 ) { for (int g = 0; g < yards; g++ ) { Console.WriteLine ("Ra!Ra!Ra!Ra!Ra!"); } } else if (yards > 10) { Console. WriteLine ("High Five"); } } } }
21st Feb 2020, 7:34 PM
GAG98
GAG98 - avatar
0
a bit too Raa! one for each yard is enough😉
21st Feb 2020, 7:37 PM
Oma Falk
Oma Falk - avatar
0
And what a mistake with Tolnt?
21st Feb 2020, 7:52 PM
GAG98
GAG98 - avatar
0
usercode/file0.(cs14,19): error CS0117: 'Convert' does not contain a definition for 'Tolnt32'
21st Feb 2020, 7:58 PM
GAG98
GAG98 - avatar
0
Gleb Be carefull you wrote lnt with "L" not with "I"
21st Feb 2020, 8:13 PM
Mihai Apostol
Mihai Apostol - avatar
0
When you had a string saved, use Convert.ToInt32. If you havent had already, use int.Parse()
21st Feb 2020, 8:20 PM
Trần Tân An Nguyễn
Trần Tân An Nguyễn - avatar
0
Thanks man
21st Feb 2020, 8:40 PM
GAG98
GAG98 - avatar
0
Gleb glad to help
22nd Feb 2020, 5:04 AM
Trần Tân An Nguyễn
Trần Tân An Nguyễn - avatar