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; } } }
7 Respostas
+ 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..
+ 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...
+ 2
for(int n=0; n<yards; n++) {
System.out.print("Ra!") ; } // prints yards times
See the loop lesson in course, before trying further...
+ 1
Thank you, didn't realise I put a t on the end of System.in
How would you run a loop for Ra!
+ 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
+ 1
Thank-you, I appreciate it!
+ 1
You're welcome..