I'm new to Java and I have tried repeatedly to fix this... I have thirty errors
* @(#)Input.java
*
* Input application
*
* @author
* @version 1.00 2015/6/24
*/
import javax.swing.JOptionPane;
import java.util.Random;
public class Input {
public static void main(String[] args) {
// TODO, add your application code
String name = JOptionPane.showInputDialog("Rock, Paper, or Scissors?");
System.out.println(name+"!");
Random rn = new Random();
random.nextInt(10 - 1 + 1) + 1;
}
if (name.equalsIgnoreCase("Rock")){
if (0<randomInt && randomInt<4){
System.out.println("Paper! You Lose!");
}
else if(4<= randomInt &&randomInt <=6){
System.out.println("Rock! We Tied!");
}
else{
System.out.println("Scissors! You Win!");
}
}
if (name.equalsIgnoreCase("Paper")){
if (0<randomInt && randomInt<4){
System.out.println("Scissors! You Lose!");
}
else if(4<= randomInt &&randomInt <=6){
System.out.println("Paper! We Tied!");
}
else{
System.out.println("Rock! You Win!");
}
}
}
if (name.equalsIgnoreCase("Scissors")){
if (0<randomInt && randomInt<4){
System.out.println("Rock! You Lose!");
}
else if(4<= randomInt &&randomInt <=6){
System.out.println("Scissors! We Tied!");
}
else{
System.out.println("Paper! You Win!");
}
}
}
When it is ran:
--------------------Configuration: Input - JDK version 1.7.0_05 <Default> - <Default>--------------------
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:22: error: not a statement
random.nextInt(10 - 1 + 1) + 1;
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:26: error: illegal start of type
if (name.equalsIgnoreCase("Rock")){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:26: error: <identifier> expected
if (name.equalsIgnoreCase("Rock")){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:26: error: ';' expected
if (name.equalsIgnoreCase("Rock")){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:26: error: illegal start of type
if (name.equalsIgnoreCase("Rock")){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:26: error: <identifier> expected
if (name.equalsIgnoreCase("Rock")){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:26: error: ';' expected
if (name.equalsIgnoreCase("Rock")){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: illegal start of type
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: <identifier> expected
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: ';' expected
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: > expected
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: illegal start of type
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: '(' expected
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: <identifier> expected
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: illegal start of type
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:27: error: <identifier> expected
if (0<randomInt && randomInt<4){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:28: error: '(' expected
System.out.println("Paper! You Lose!");
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:28: error: illegal start of type
System.out.println("Paper! You Lose!");
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:28: error: ';' expected
System.out.println("Paper! You Lose!");
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:28: error: invalid method declaration; return type required
System.out.println("Paper! You Lose!");
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:28: error: illegal start of type
System.out.println("Paper! You Lose!");
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:30: error: class, interface, or enum expected
else if(4<= randomInt &&randomInt <=6){
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:32: error: class, interface, or enum expected
}
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:35: error: class, interface, or enum expected
}
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:40: error: class, interface, or enum expected
}
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:43: error: class, interface, or enum expected
}
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:46: error: class, interface, or enum expected
}
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:52: error: class, interface, or enum expected
}
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:55: error: class, interface, or enum expected
}
^
C:\Users\gw\Documents\JCreator LE\MyProjects\Input\src\Input.java:58: error: class, interface, or enum expected
}
^
30 errors
Process completed.
答案 0 :(得分:1)
答案 1 :(得分:1)
答案 2 :(得分:1)
答案 3 :(得分:1)
答案 4 :(得分:0)