How To Make Own Powerball Input System

Dec 5, 2014

Below is all the coding I have done trying to make my own Powerball input system. I am really struggling on how to fix this. I keep getting an ArrayOutOfBounds exception except, I don't know how to fix this to make it where it will check the numbers without screwing up with everything.

Java Code:

import java.util.Scanner;
public class PowerballTest
{
Scanner input = new Scanner(System.in);
public static void main(String[] args)
{
Powerball.readInput();
Powerball.writeOutput();

[Code] ....

This is the problem i keep seeing when the test run happens :

Enter the first Powerball number which should be greater than 0 and less than 60
2
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at Powerball.checkNumber(Powerball.java:73)
at Powerball.readInput(Powerball.java:23)
at PowerballTest.main(PowerballTest.java:9)

(Don't know if should have formatted that^)

View Replies


ADVERTISEMENT

How To Make The Program Understand 10 Number System

Oct 24, 2014

I want to create a program where i can output a number. ex. 3452 And the program will output 3000: three thousand 5: five 53: fifty-three

How can i make the program understand the 10-number system?

View Replies View Related

How To Make A Model Of Solar System - Have Sun And Earth Revolving Around It

Oct 25, 2014

I'm attempting to make a model of the solar system. Up till now, I have a Sun and the Earth revolving around it. The problem I have is when I add inheritance to the program. The moon that I created does not orbit the Earth.

Here's my code for the classes I've created

public class Driver {
public static void main(String[] args){
SolarSystem model = new SolarSystem(700, 700);
/* Create new instances of each object in the solar system */
SunObject sun = new SunObject();
PlanetObject earth = new PlanetObject(140, 30, 15, "BLUE", 2);
MoonObject moon = new MoonObject(15, 30, 2, "WHITE", 1.5);

[Code] ....

Note that SolarSystem is a class given to me. That contains all the paint methods. I'm just creating new instances with the drawSolarObject()

And the drawSolarObjectAbout takes an extra two parameters:

centreOfRotationDistance - the distance part of the polar co-ordinate about which this object orbits.
centreOfRotationAngle - the angular part of the polar co-ordinate about which this object orbits

I have a PlanetObject class:

public class PlanetObject extends PointInSpace {
private double distance;
private double angle;
private double diameter;
private String colour;
private double speed;

[Code] ....

And a MoonObject class, which is EXACTLY the same as the PlanetObject class. The main problem I'm having is when I extend my PlanetObject class to a PointInSpace class below:

public class PointInSpace {
private double distance;
private double angle;
public double getPointDistance(){
return distance;

[Code] .....

What I'm trying to do is use the distance and angle in the PointInSpace class so that my Moon can orbit those two coordinates . I get it working when I method override when drawing the moon - using earth.getDistance() instead of earth.getPointDistance() etc. Have I inherited properly? Should I try a method overloading process instead?

View Replies View Related

How To Make Custom Texture System For A Block In Minecraft

Apr 20, 2014

I am trying to make a custom texture system for a block in Minecraft, I am not too advanced with Java and am not sure how to make this work the way I want it to.

/** The list of the types of step blocks. */
public static final String[] blockStepTypes = new String[] {"stone", "sand", "wood", "cobble", "brick", "smoothStoneBrick", "netherBrick", "quartz"};
  private Icon missing;
private Icon icon1;
 
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/

[Code] .....

Alright, so basically I figured I could just tell the code to see if the block is made out of Stone, then to set the texture to Stone, or if it's made out of Sand, then set it to Sand.

What I usually get is Eclipse telling me to "insert '!= null' check", "insert '!= null' check", and then just error out saying "Opperator != is undefined for the argument type(s) boolean null"

Is there any way I could make this work for me? Maybe some other way to make it do what I am trying to do?

View Replies View Related

How To Convert System Input Into Array

Jul 18, 2014

Creating an array searcher wherein it all depends on the user input. On the first user input it would be the array to search from while the second input would be something to be searched for inside the loop?

View Replies View Related

Grading System Where In Can Detect If Notepad Has This Input

Sep 25, 2014

on my note pad the 00 means that it is an excused absent while 0 is the unexcused:this one is the readfile saved on .txt

Bruce Wayne
9 9 00 19 49
10 0 10 9 9
90
50
87 87
some of the code:

if (inFile.next() == 00){
System.out.print("student has an excused absent how would you like to proceed");

}else{
grade = inFile.nextDouble();
qsum += grade;

View Replies View Related

Averaging Grades Program - System Crashes On Negative Number Input

Sep 30, 2014

I do now have the problem where i have to insert the numbers 1 to 100 individually in order to allow the program to accept a grade as high as 100%.

Also as soon as i type in a negative number the system crashes and shows me a error as attached.

/*
Averaging grades
To use the Java Swing interface to calculate the average of up to 50 grades.Average is calculated once -1 is entered as a value. The grades are then sorted from lowest to highest and displayed in a content pane which also displays the average.
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing .*;
import javax.swing.text.*;
public class Averages extends JFrame {
//construct components
JLabel sortPrompt = new JLabel("Sort By:");

[Code] ....

View Replies View Related

Make A Program Which Take Input From Keyboard And Count Numbers

Sep 12, 2014

import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number;
System.out.println("Input a number");

[code]....

What i want to do is that if the number is greater than 50 to count until 100. else if the number is less than fifty to count for example from 36 to zero.

View Replies View Related

Make Library That Will Read Some Input Files From A File?

Apr 23, 2015

I am trying to make a Library that will read some Input Files from a File . Like When We Enter Nuber from a System.in

1
2
45
667

77
34

and then store these values in int[] array

What I want is I Save all these values in a File and at Run time pass path of that file to command line arguments and then int[] array will be initialize using that

something like this [URL]

View Replies View Related

User Input 3 Sides - Output Invalid If Does Not Make A Triangle

Nov 4, 2014

I had to make a program that allows the user to enter 3 sides and it should output "invalid" if it does not make a triangle and if it does make a triangle it calculates the area of the triangle and it doesnt seem to do anything but say "invalid" as the out put.

import java.util.Scanner;
public class MyTriangle {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean valid = true;
double side1, side2, side3, area, A;
 
[Code] ....

View Replies View Related

How To Make File Reader Object Move To Next Line If There Is No More Input On Line

Feb 18, 2015

How do I make the file reader object move to the next line if there is no more input on the line. Here is my text and output file as you can see that my text file column cuts off on the 2nd line after 70. I want to read that next line which is 100 into my labs variable however its reading it into my final exams variable. I'll also post the code but I didn't think it was necessary.

textfile:
100908095
1008070
10070

output:
Labs Projects Tests Final Exams
100908095
1008070100
70

[import java.util.Scanner;
import java.io.*;
public class MyGrades
{
public static void main (String[] args) throws IOException
{
int lab, project, test;
int finalExam;//Par and Player values

[Code]...

not sure if I code wrapped it correctly

View Replies View Related

Make Shapes Besides Making Two Lines For X And Oval With White Smaller Oval Inside To Make O

May 8, 2014

We are making a tic tac toe game for my CS120 class and I am having trouble figuring out how to make our X's and O's. Is there a way to make shapes besides making two lines for an X and an oval with a white smaller oval inside to make an O? We have only learned the basics so far in class (i.e. events, inheritance, client-supplier, etc.)

These are our instructions:

Write a controller that controls the game. There is one human player (the X player) and the computer player (the O player). The name of the class must be TicTacToeController. In a sense, the controller is the game since the controller will 1) create a TicTacToeModel 2) create a TicTacToeView and 3) create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game. While you are free to change the appearance of the controller, the basic elements must be provided (a view of the game, a button, and a text field to enter the cell). A sample screenshot is displayed below.And this is the code i have thus far:

[import java.awt.*;
import javax.swing.JFrame;
public class TicTacToeView extends Rectangle
public TicTacToeView(int x, int y, int w, int h) {
super(50,60,w,h);
this.setBackground(Color.red);
JFrame win = new JFrame("Tic Tac Toe");
win.setBounds(10,10,w+100, h+100);
win.setLayout(null);
win.setVisible(true);
win.setBackground(Color.gray);

[code]....

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

Create Program That Prompts Input And Creates File With That Input As Name

Jul 14, 2014

So I was going to try to create a program that prompts input and creates a file (That didn't exist before) with that input as name.Then, the program prompts inputs after stating questions such as 1 + 1, then if the user inputs an answer, put "Question # = Correct "or" Wrong.Code SO Far:

Java Code:

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
public class File_Read {
public File_Read() {//File_Read is the Interactive object

[code]....

So that it puts the Correct or Wrong into the file.

View Replies View Related

The System Cannot Find The Path Specified

Feb 25, 2015

I have the Java Development Kit downloaded in my C file and my book tells me to compile the program I need to open command windowand change the directory where the program is stored. I tried the command cd to change directory and received this message "The system cannot find the path specified."

I checked the Environment Variables on Windows 7 and the Path says: C:Program Files (x86)Javajre1.8.0_31in

This is after many tries and i still can't change directory and i keep getting the same message.

View Replies View Related

Stock System In Java

Jan 6, 2015

I'm making a stock system for the heck of it,so everything was going great until I hit the loop I am trying to use a for loop to add stock to the stock system,any way the question is maily about loops.How come I cannot declare a variable outside a loop and assign a value to it,for example I can declare as follows and I will not get an error,

for(int i=0;i<10;i++){
System.out.println("example");

}

but in my code(and yes its the only error I get I tested it) I get an error and can only declare and assign a value inside the loop,the reason for this is because I wanted to get the value from another class and use it in the loop ok so heres the code from both classes.

public class mainn{

public static void main(String [] args){
stock first = new stock();
int internal;
internal = first.wanted;

[code]....

View Replies View Related

Ordering System In Eclipse?

Jul 22, 2014

it gives me an error at the end class part some syntax error insert "}"..

* Course: IT110 - Introduction to Programming
* Filename: MyCustomShirtsPhase1.java
*
* Purpose: Created a simple online ordering system for My Custom Shirts customers
*/
import javax.swing.JOptionPane;

[code]....

View Replies View Related

System Cannot Find Path Specified

Feb 24, 2015

I have the Java Development Kit downloaded in my C file and my book tells me to compile the program I need to open command windowand change the directory where the program is stored. I tried the command cd to change directory and received this message "The system cannot find the path specified." I checked the Environment Variables on Windows 7 and the Path says: C:Program Files (x86)Javajre1.8.0_31in

This is after many tries and i still can't change directory and i keep getting the same message.The book I am using to learn Java is "Java How to Program: Tenth Edition" from Paul and Harvey Deitel.

View Replies View Related

Building A Registration System

Jan 18, 2015

I'm assigned along with two others to make this program for a project.

We need to store data to the program by adding them such as user_id among the 5 criterias that are needed. Lets say I want a new user, I need the program to give me that option and then I would type in the user id and the program would store that data information

As far as I'm aware, boolean, screentokenizer and scanner is involved in the making of this program.

View Replies View Related

How To Find IP Address Of System

Dec 5, 2013

In my java program I'm changing my IP(using proxy) and sending the request to some sites. Later some point of time, I want to know my current IP address through java program itself. How to get hold of my current IP address? Also which IP address will it show? The proxy one or the original IP ?

View Replies View Related

Banking System Using Access DB

Mar 13, 2015

I have designed a code that is aimed at simulating a banking environment using access database. However, there are errors and i am not able to create a new account.

import java.awt.*;
import java.awt.event.*;
import java.awt.FlowLayout;
import java.sql.*;
import javax.swing.*;
public class Bank extends JFrame implements ActionListener

[Code] ......

View Replies View Related

How To Get System Time In Java

Jun 1, 2014

I just want to calculate search time for my algorithm . How to get system time in java other than System.nanotime() and System.currenttimemillis() as these methods does not returns consistent time for same input is their another option to get system time???

View Replies View Related

Number System Converter

Feb 15, 2013

This program requires knowledge of manipulation of Java String objects and methods. It also requires knowledge of Number System Conversions.

// Lab16MATH05st.java
// The Number System Converter
// This is the student, starting version of the Lab16MATH05 assignment.

import java.util.Scanner;
public class Lab16MATH05st
{
public static void main (String args[])
{
System.out.println("Lab16MATH05 - Number Conversion Program

[code]....

90-Point Version Specifics: The 90-point version requires that you write both the fromHexToBin and fromBinToDec methods.

90-Point Version Output

95-Point Version Specifics {The 95-point version requires everything from the 90-point version and adds the fromBinToHex method. For this version, you may assume that the binary number will have a multiple of 4 bits.

95-Point Version Output

100-Point Version Specifics: The 100-point version requires the same methods as the 95-point version; however, the fromBinToHex method needs to be improved so it can convert regardless of the number of bits.

100-Point Version Output

105-Point Version Specifics: The 105-point version requires everything from the 100-point version and adds the fromDecToAny method. For this version, the method needs to be able to convert from decimal to any base between 2 and 10. Base 16 is not required for this version.

105-Point Version Output

110-Point Version Specifics: The 110-point version requires the same methods as the 105-point version; however, the fromDecToAny method needs to be improved so it can also convert to base-16.

View Replies View Related

Time Management System

Oct 27, 2014

I'm in the middle of building A time management system for myself.I'm currently using JodaTime for timing in java. I just can't figure out who to save my data like, the starttime, stoptime and day time.

public void save() throws SQLException {
String checkSql = "select count(*) as count from Time where id=?";
PreparedStatement checkStmt = con.prepareStatement(checkSql);
String insertSql = "insert into Time (id, day, starttime, stoptime, overtime, exception, hours) values (?, ?, ?, ?, ?, ?, ?)";
PreparedStatement insertStatement = con.prepareStatement(insertSql);

String updateSql = "update Time set day=?, starttime=?, stoptime=?, overtime=?, exception=?, hours=? where id=?";
PreparedStatement updateStatement = con.prepareStatement(updateSql);

[code]....

View Replies View Related

Digital Signage System

Jul 1, 2014

I am going to try and write a server-client based system.The server will be the design of what I want (e.g: daily advertisements that will be displayed on big monitors connected to the client, with like a slideshow looping). The client will just be receiving information from the server and not doing anything with it except displaying it and perhaps a networking element of the client reporting back to the server if the connection is dropped etc. The administrator can use the server to change the look of the advertisement.

I need the server to PUSH OUT to the client computers.I am on a networking degree so there has to be some elements to networking connections going on and programming is not my strong point. Would I write the server and clients in Java or another program? Will there need to be a "middle" program such as a web server?

View Replies View Related

Grading System Program

Aug 20, 2014

Ok so this is a grading program. I have it so the user can input 2 students and then at the end using an if statement it is suppose to compare them and print out who had the higher grade. Seems simple but it never runs the line of code to print out whos grade is higher:

if (stuAverage > stuAverage2 ){
System.out.println(student + " has the highest grade of all students entered!");
}
else if (stuAverage2> stuAverage){
System.out.println(student2 + " has the highest grade of all students entered!!");
}

Here is the Main class:

import java.util.Scanner;
public class Main2 {
int stuAverage;
static String student;
 
[code]....

View Replies View Related







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