Error When Compiling Rock Paper Scissors
Nov 7, 2014
When I try to compile the code it says " method determineWinner in class RPS cannot be applied to given types;" I think there is something wrong with the way i called the determineWinner method but i'm not what exactly is wrong.
public class RPS
{
public static void main( String [] args )
{
String result;
String userName = getUserName();
String playerChoice, computerChoice;
[code]....
View Replies
ADVERTISEMENT
Feb 18, 2014
I was wondering how I could make this code for rock paper scissors repeat itself 10x
import java.util.Scanner;
import java.util.Random;
public class Rock {
public static void main (String [] args) {
[Code] .....
View Replies
View Related
Jan 3, 2015
im trying to modify the class to include a playerName variable and methods named assignName and getName. The assignName() method has a String parameter name that is assigned to playerName. The getName() method has to return the value of playerName.the problem i have when i run it is that it says there is a problem in the
public static String getName(){
return getName();
but im not sure what it is, this is all of my code:
public class RPS1 {
public static void main(String[] args) {
RPSGame rps = new RPSGame();
RPSPlayer rpsOpponent = new RPSPlayer();
int playerThrow;
Scanner input = new Scanner(System.in);
[code]....
View Replies
View Related
Jun 23, 2014
I am trying to program a game of RPS.
View Replies
View Related
Nov 7, 2014
When I try running the program it wont output the determineWinner method, I think there is something wrong with the way i called results. But I am not exactly sure?
public class rpsGame
{
public static void main( String [] args ) {
String userName = getUserName();
String playerChoice, computerChoice;
computerChoice = getComputerChoice();
[Code] ....
View Replies
View Related
Jan 8, 2014
See code.
import java.util.*;
public class CQ1v1{
public static void main(String args []) {
Scanner in = new Scanner (System.in) ;
String name = "";
System.out.println("Welcome to the Interrogator") ;
[Code] ....
When I compile getting
CQ1v1.java:12: error: cannot find symbol
x = in.nextLine ();
^
symbol: variable x
location: class CQ1v1
CQ1v1.java:21: error: cannot find symbol
[Code] ...
View Replies
View Related
Oct 18, 2014
I am trying to create an array where each object includes a service description, price, and time in minutes. I have a Service class and a SalonReport class:
import java.util.*;
public class Service
{
public String serviceDescription;
public double servicePrice;
public int timeMinutes;
[Code] ....
When I compile this, I get an error message that says:
SalonReport.java:8: error: constructor Service in class Service cannot be applied to given types;
salonServices[0] = new Service("Cut", 8.00, 15);
^
required: no arguments
found: String,double,int
reason: actual and formal argument lists differ in length
What this error message means and how I can correct it? I am confused because my SalonService() method has (String service, double price, int minutes), and each object is listed in that exact order.
View Replies
View Related
Jun 11, 2014
I keep getting this error upon compiling and can't see the problem with it.
The error is on line "45: 15"
/* 37: */ public static EntityDef forID(int i)
/* 38: */ {
/* 39: 10 */ for (int j = 0; j < 20; j++) {
/* 40: 11 */ if (cache[j].type == i) {
/* 41: 12 */ return cache[j];
[Code] .....
View Replies
View Related
May 21, 2015
I am getting a compile error message when I am trying to compile someone else code using Eclipse. The partial code description is below as follows:
public String decrypt(String password) {
try {
// create the key and parameter spec
KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, interactions);
SecretKey key = SecretKeyFactory.getInstance(keyFormat).generateSecret(keySpec);
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, interactions);
[Code] ....
Below is the following error message:
Access restriction: The type 'BASE64Decoder" is not API (restriction on required library '/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rd.jar')
How do I troubleshoot it?
View Replies
View Related
Apr 12, 2015
I have an input text file as file.txt where, it consists of only real values separated with commas, and arranged as rows as columns as mentioned below :
1,2,3,4,5,6,10,5,8,9
1,4,7,8,9,0,6,4,3,2,1
2,4,5,8.1.3.4.6.7.9.0
the number of rows is 100 and the number of columns are 9, that is they are fixed.Above is just an example, the file consists of decimal values.What I require is for each column of values I need to find out it's average or mean, that is in above example,
for 1st column:(1+1+2)/3
for 2nd column(2+4+4)/3
for 3rd column(3+7+5)/3,,,,,,,like this till the last column.
So I need to take the input from the .txt file, calculate the column average of each column and the average of each column must be displayed as output. I have done a bit of coding, but it is giving a run-time error as NullPointerException.I will forward my code as attachment, the reading of file, is done as string in java and then it must be converted to double values, also to read the comma separated input from a file I have used the split().
View Replies
View Related
Apr 11, 2013
class Test1
{
public static void main(String args[])
{
void show()
{
System.out.print("its working");
}
show();
}
}
When I compile this program i find the error illegal start of expression
^void show
Test1.java5 ';' is expected
View Replies
View Related
Jan 22, 2015
I made a web app to test the ServletContextListener in tomcat according to the book head first servlets and jsps and used the code
out.println("test context attributes set by listener<br>");
Dog dog = (Dog) getServletContext().getAttribute("dog");
out.println("Dog's breed is: "+dog.getBreed());
in the listener class.But the output is showing the first line only and the second println() is not showing any output whereas my Dog class compiled successfully and I didn't see any NullPointerException as expected in the book but somehow it seems like the problem is in the 2nd line of code only but I don't know what.
I also tried to add a 4th line at the end with println() only but with a simple text even that is not running but when I put that same line after the 1st line, the output is shown.I am unable to see what has gone wrong in the 2nd line of code.
View Replies
View Related
Jan 23, 2013
I am a beginner want to compile servlet with following path
javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java
Problem arises as follows:
javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options
View Replies
View Related
Mar 31, 2014
I have created a program that will take in input of paper names and authors. The next step of the program is to make references from paper to paper, and be able to add as well as list those reference, and i am lost as to where to go.I currently hold my instances of my paper class (the different papers I have stored) in a hash map. With the title being the key.
Is there a method as to where I can link keys? Do i need to use a seperate data structure? Or maybe add a new attribute to the paper class? I have attached the program as a zip file, If you open the zip file then its the methods in the Research SupportApp class .
View Replies
View Related
May 2, 2014
I am having trouble while printing out form. So far I have succeeded to print it out.But my question is that I want jpanel to print out in Landscape rather then portrait.
View Replies
View Related
Jun 28, 2014
the number of lines that can be printed on a paper size, the point size of each character in a line, whether lines are double-spaced or single-spaced,the top and the bottom margins of the paper. assume that all characters are of the same point size, and all lines are either single-spaced or double-spaced. note that 1 inch = 72 points. make over, assume that the line are pointed along the width of the paper. for example, if the length of the paper is 11 inches and the width is 8.5 inches,then the maximum length of a line is 8.5 inches.write a program that calculates the number of characters in a line and the number of lines that can be printed on a paper based on following input from the user.
a.the length and width, in inches, of the paper.
b.the top, bottom, left, and right margins.
c.the point size of a line.
d. if the lines are double-spaced, then double the point size of each character
View Replies
View Related
Nov 19, 2014
why my program doesn't work. Here's the code :
public test5 {
public boolean test(int grille[][]){
for (int i = 0 || i < grille.length || i++){
int max = grille[i][0];
for (int e = 1 || e < grille[i].length || j++){
if (grille[i][e]== max && max !=0){
solution = false;
System.exit(1);
[code]....
View Replies
View Related
Feb 27, 2015
So say I write up a program like a dice roll game, which I see on the forums here. It's all written and good to go and when I hit Run it does what I want it to do, no errors..What do I do with those .class and .java files? Do I compile it somehow into an app I can put on the google play store? What is the NEXT STEP after the program is all written?
View Replies
View Related
Feb 9, 2014
I get quite a few errors while trying to compile the BeerSong from the Head First Java book. I copied the text from another person that did the beer song on this forum and it worked as expected. What I can't figure out is why mine is not working when it looks like the text is exactly the same between the two versions. His works, but mine doesn't.
Here is the text and errors that I get:
public class BeerSong
{
public static void main (String[] args)
{
int beerNum = 99;
String word = "bottles";
[code]...
View Replies
View Related
Feb 16, 2012
Create a class named Commission that includes three variables: a double sales figure, a double commission rate, and an int commission rate. Create two overloaded methods named computeCommission (). The first method takes two double parameters representing sales and rate, multiplies them, and then displays the results. The second method takes two parameters: a double sales figure and an integer commission rate. This method must divide the commission rate figure by 100.0 before multiplying by the sales figure and displaying the commission. Supply appropriate values for the variables, and write a main () method that tests each overloaded method. Save the file as Commission.java
b. Add a third overloaded method to the Commission application you created in Exercise 1a. The third overloaded method takes a single parameter representing sales. When this method is called, the commission rate is assumed to be 7.5% and the results are displayed. To test this method, add an appropriate call in the Commission program's main () method. Save the application as Commission2.java
COMMISSION.JAVA
public class Commission
{
public static void main(String[] args)
{
double Sales = 10000;
double commRate = 0.075;
int rate = 7;
computeCommission(Sales, commRate);
computeCommission(Sales, rate);
}
public static void computeCommission(double Sales, double commRate)
[code]....
View Replies
View Related
May 6, 2015
I am watching BrandonioProductions on youtube. His videos are pretty good, but he doesn't seem to get errors where I get them. Here is an example.
public class compareUnequal {
public static void main(String[] args){
compareTwo();
}
public static void compareTwo(){
String x = "david";
String y = "Notdavid";
if (!x.equals(y)){
System.out.println("Not equal");
}
}
}
It runs ok, but asked me to proceed when there is an error, but I can`t figure out where the error is!
View Replies
View Related
Dec 11, 2014
I am using Oreilly Head First Servlet book and having trouble in compiling servlets from cmd.
Tomcat path is : C:Program FilesApache Software FoundationTomcat 6.0
Below is compiling result
C:ProjectseerV1>javac -classpath "%TOMCAT_HOME%libservlet-api.jar:"classes:
. -d classes src/com/example/web/BeerSelect.java
srccomexamplewebBeerSelect.java:3: error: package com.example.model does not
exist
import com.example.model.*;
^
srccomexamplewebBeerSelect.java:4: error: package javax.servlet does not exi
st
import javax.servlet.*;
[Code] ....
14 errors
C:ProjectseerV1>
View Replies
View Related
Oct 30, 2014
I am getting an error as follows while trying to compile a java file for servlet:-
"error while writing BeerSelect: WEB-INFclassesBeerSelect.class (Access is denied)
public class BeerSelect extends HttpServlet
^
1 error"
I am using "C:Program FilesApache Software FoundationTomcat 8.0webappsBeerBottlejavac -d WEB-INFclasses BeerSelect.java" to compile the file.
I am using Windows 8.1
View Replies
View Related
Jun 30, 2014
String filename="C:UsersRajashekarDesktopfwfwdSoftware Failures1_Test.txt";//Input Files
String data;
public ArrayList<String> value=new ArrayList<String>();
public void read() throws IOException{
File f = new File(filename);
[Code] ....
View Replies
View Related
Mar 22, 2014
I made a software using Netbeans and javaswing. Accidently i deleted my main file which contains my main class and main method. Just to test, i tried to compile and run and it worked but the style of my buttons and windows has changed. So, what happened? How can i change the style of my programs?
//File Accidently deleted
package time;
public class Time {
public static void main( String[] args ) {
Window wdow = new Window();
wdow.setVisible( true );
}
}
View Replies
View Related
Feb 11, 2015
I am new in java. I executed a java program using eclipse. the program contain two java file. when i try to run it using terminal in Ubuntu. Two files are not linking. it shows error. i am attaching all the data.
It shows the following error
regex2string.java:83: error: cannot find symbol
str = randomstr.nextString(2000);
^
symbol: variable randomstr
location: class regex2string
1 error
[Code] ...
View Replies
View Related