Code Won't Output Rock Paper Scissor Results

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


ADVERTISEMENT

Rock Paper Scissors Repeat Itself 10x

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

Rock Paper Scissors Java

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

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 View Related

Applets :: Program A Game Of Rock Paper Scissors?

Jun 23, 2014

I am trying to program a game of RPS.

View Replies View Related

Exam Results - Code Should Split Results In Stars In 4 Categories

Nov 30, 2014

I'm doing a program where a user enters in exam results for students. Once he's entered the code, the code should split the results in stars in 4 categories.

I am working with a while loop that prints out infinite results. What I want to do is, if the user enters 2 digits, say "12", it should output 1 "*".

If the user enters "21" and "22", it should output "**".

There are 4 categories of marks which are marked with ints range1, range2, range3 and range4, which are user enter digits. Part 1 of the code is to split the user entered digits into its correct ranges. the ranges are 0-29, 30-39, 40-69 and 70-100. I've done the part where when the user enters a digit, it goes into the correct variable. After that when the user enters a digit over 100, the enter results should show up as stars. For example

Enter number =

21
22
44
66
44
23
11
111 (the 111 is where the program breaks and moves on)

So it should then display

0-29 ****

30-39

40-69 ***

70-100

Whatever I'm trying, it displays an infinite amount of stars. If I try to use break, It only outputs a single star, no matter how many digits I enter

Here is the code

int mark = 0;
int range1 = 0, range2 = 0, range3 = 0, range4 = 0;
int count1 = 0, count2 = 0, count3 = 0, count4 = 0;
while (mark >=0 && mark <=100) {

[Code] .....

"The problem is with the while loop, the one above is something I was experimenting with "

View Replies View Related

Input Color Code In HSV And Output Equivalent RGB Code

Oct 9, 2014

I need to create a Java program that takes an input a color code in HSV and outputs the equivalent RGB code and Vice versa.

Example:
If you test on the color RED in RGB:
Input: (255,0,0)
Output: (0,100%,100%)
If you test on the color RED in HSV:
Input0,100%,100%)
Output: (255,0,0)

View Replies View Related

Output Of Code Showing Different Value?

Jan 13, 2014

I have one code [taking from on line SCJP exam preparation site]. I have 2 question in my mind:

1) addValue() is non static method then why it is running without object inside constructor. By this rule it should show compilation error.
2) With ref variable of parent always non overridden methods of parent run then it must value of 10 [If i forgot 1st point ]

But it is giving 40. Code is as below:

class Base{
int value = 0;
Base(){
addValue();
}
void addValue(){
value += 10;

[Code] .....

View Replies View Related

Get Code To Stop Overwriting The Output?

May 1, 2014

What I mean is, I have this set and it is supposed to take out all the duplicates. If I enter aaabbbcccd the output should be abcd, but instead my code just outputs the last word, or in this case letter entered.

import java.util.*;
public class setdemo
{
public static void main(String[] args)

[Code]....

View Replies View Related

Improve Code To Output A Word With Most Frequent Letter?

Jan 31, 2015

The code is supposed to output a word from a sentence(from a sample file) with most frequently occurring letter in that word.

Example input: "Therefore, it is this word."

output: therefore

It currently uses 3 loops nested loops, is there a way to improve this?

public static String findWord(String file) throws IOException {
BufferedReader in = new BufferedReader(new FileReader(file));
String text, correctWord = null;
text = in.readLine();
StringTokenizer tokens = new StringTokenizer(text.toLowerCase(), " ,.?"); //split string into tokens of words only
int count = 0, numLetter = 0;

[code]....

View Replies View Related

Program To Read Input Of Morse Code And Then Produce Output Of English

Aug 25, 2014

I'm having some trouble with getting this program to read an input of morse code and then produce an output of English. When typing in morse code for the phrase 'the string', the output looks something like this:

- .... .
t
h
... - .-. .. -. --.
s
t
r
i
n

The English-->Morse works just fine.

import java.util.Scanner;
public class project1
{
static final String[] alpha = {
"a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r",
"s", "t", "u", "v", "w", "x", "y", "z", " "

[Code] .....

View Replies View Related

Paper Referencing Program

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

How To Set Printer Paper Size To Same As Jframe

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

Number Of Lines That Can Be Printed On A Paper Size

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

Generate QR Code From Input Text And Display Information About Input / Output Bits

Nov 12, 2014

I am trying to write a program that will generate a QR Code from an input text and also display some information about the input/output bits. So far I have created the frame and what to do next. And I'm not sure if I am on the right track since my level of programming is not that great. By the way, I am using zxing libraries from GitHub. I know, there are plenty of generators online for the QR Code, but that is not what I am looking for. As you can see on the attached image, I am more interested in the efficiency of encoding 2D data. Also, I noticed that almost all the online projects regarding 2D codes are for Android. Which is not very useful.

// QR Code Generator
package qrcode;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

[Code]....

View Replies View Related

ProcessBuilder No Results

Feb 23, 2014

try {
ProcessBuilder PB=new ProcessBuilder("find","/","-iname",""vim"");
PB.redirectOutput(Redirect.INHERIT);
PB.redirectError(Redirect.INHERIT);
PB.start();
}
catch (Exception e) {
e.printStackTrace();
}

It shows nothing. But when I tried

new ProcessBuilder("uname");

I gets a result ....

View Replies View Related

Why Terminal Not Returning Results To IDE

May 14, 2014

i am trying to run a command in terminal the code is below if i run the command in terminal it works fine however when i run it from netbeans with code below nothing gets printed. however if i run a different command such as (ip addr) it works fine?

public static void a() throws IOException{
ArrayList lister=new ArrayList();
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("ps -ef | grep firefox");// the command i am trying to run to get pid of application
InputStream stderr = proc.getInputStream();

[Code] ....

View Replies View Related

Printing Results From A Method

Apr 27, 2014

I need to print certain information from an arraylist depending on the arguments the method has. I'm trying to print the last 3 methods from the database class but nothing is printing and I don't know what the problem is.

package hw3;
import java.util.*;
public class Driver {
public static void main(String[] args){
/* Comments required
PersonFileReader pfr = new PersonFileReader("person.dat");
ArrayList<Person> testData = pfr.readData();
Database db = new Database(testData);
*/

[Code] .....

On the driver class I just print what the methods from the database class do.

View Replies View Related

JSF :: Jsf2 Search Results Not Displaying?

Apr 27, 2014

I develop a little app in javaee6 and jsf2. I have a search page which has a search form with 2 fields and a search button when i click search button the results should be displayed in searchresults page.

Here is my code,

search.xhtml page
<h:form id="searchform">
<h:inputText id="deptId" value="#{searchBean.departmentId}"></h:inputText>
<h:inputText id="deptName" value="#{searchBean.deparmentName}"></h:inputText>
<h:commandButton value="Click to Search" action="#{searchBean.searchEmployees}">

[code]...

Issue: searchresults page is is not displaying records though it fetched records from table I'm able to achieve this using search bean as session scope but i want to use the scope as Requestscope.

View Replies View Related

Swing/AWT/SWT :: Displaying Results In A Message Box?

May 8, 2014

how to display results in a PLAIN_MESSAGE. My program is converting hex to decimal and displaying the results. Here's the code:

package pkgfinal;
import javax.swing.JOptionPane;
import java.util.Scanner;
public class Final {
public static int Convert(String userInput, int base){
int running_sum = 0;

[code].....

View Replies View Related

Swing/AWT/SWT :: Using SetText To Display GUI Results

Feb 15, 2015

I have the code here to populate a GUI. I have the math and then print out and return a single number. I have tried to use setText in the class CalculateButtonHandler.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class RectangleProgram extends JFrame {
private JLabel lengthL, widthL, areaL, perimeterL, averageL;

[Code] ....

View Replies View Related

Stream To Collection - Saving Results

Mar 25, 2014

I have the following

Java Code: list.stream().sorted((s, s1) -> s.getName().compareTo(s1.getName())).distinct(); mh_sh_highlight_all('java');

I want to save the results to a collection.

I saw an video tutorial on these by Oracle learning library and they mentioned an into(collection) method but I looked at the api and there isn't one.

How can I do it?

View Replies View Related

Odd Results From Octal-decimal Converter

Mar 13, 2015

I wrote this small program to take an octal number from the user and convert it to decimal form.

import java.util.Scanner;
public class Decimal
{
public static void main (String args []) //gets octal number from user, later prints conversion
{
int octal;

[Code] .....

Some conversions work. For example, 77 will be correctly converted to 63, and 77777777 will be converted to 16777215. However, some conversions do not work. An example of this is 775002 gets converted to 74898.

View Replies View Related

How To Just Copy A Link To Results Page

Dec 17, 2014

I'm working on a simple site for my friend, and he asked me to link to his other site. I need to have the link to a specific search. For example, if I search for "Heathrow," I need to be able to link a button on the other site so that it can be clicked and directed to the search results on this page. Problem is that this is apparently all Java (which I know nothing of) and how to just copy a link to the results page.

View Replies View Related

Not Getting Correct Results In Binary Search Tree

Aug 17, 2014

I don't see any nodes that I add. Not sure why getting this error.

duplicate found
Exception in thread "main" java.lang.NullPointerException
at binarysearchtree.delete(binarysearchtree.java:111)
at binarysearchtree.main(binarysearchtree.java:196)
Java Result: 1
public class node<T>

[Code] .....

View Replies View Related

Program To Add 2 Roman Numerals Together And Return The Results

Feb 26, 2014

Writing an program to add any 2 given Roman numerals together and return the results.

[I don't want to convert Roman numbers to decimal numbers & then add together, then convert in to Roman numerials ]

Is there any direct way to add roman numerials?

For example: I + I = II
III + I = IV

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved