0

New to programming, Help on Cheer

Keeps saying <identifier> expected Line 0 import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.int); int yards = sc.nextInt(); if(yards <=1) { System.out.println("Shh!"); } else if(yards >= 10) { System.out.println("High five"); } else if(yards >= 1 && yards <= 10) { System.out.println("Ra!")*yards; } } }

15th Jan 2023, 9:52 AM
Jacob
7 Antworten
+ 1
Yes. When you deal with array travsersal, then you need index from 0 so start from 0 is the best practice. You can also n = 1 ; n <= yards; make sure use <= here..
15th Jan 2023, 10:43 AM
Jayakrishna 🇮🇳
+ 2
Scanner sc = new Scanner(System.int); // error here (System.in) ; only not int Case 1 : for less than 1 : print "shh" //check case sensitiveness.. Case 2: yards > 10 : High five"); } Case3: else if(yards >= 1 && yards <= 10) { System.out.println("Ra!")*yards; error. This is not python. You need to print "Ra" by using a loop.. from 0 to yards times...
15th Jan 2023, 9:59 AM
Jayakrishna 🇮🇳
+ 2
for(int n=0; n<yards; n++) { System.out.print("Ra!") ; } // prints yards times See the loop lesson in course, before trying further...
15th Jan 2023, 10:08 AM
Jayakrishna 🇮🇳
+ 1
Thank you, didn't realise I put a t on the end of System.in How would you run a loop for Ra!
15th Jan 2023, 10:05 AM
Jacob
+ 1
I already completed the loop lesson but it was a little confusing once adding words to be multiplied. But I have got it now, thankyou!! With setting the value for n so the loop works, would you start with Int n = 0 under the other intergers. I have done this and passed but want to know if this is common practice
15th Jan 2023, 10:28 AM
Jacob
+ 1
Thank-you, I appreciate it!
15th Jan 2023, 10:44 AM
Jacob
+ 1
You're welcome..
15th Jan 2023, 1:01 PM
Jayakrishna 🇮🇳