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:");
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)
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
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?
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?
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.
I've been pondering about this algorithm for about a week but I'm still not able to write a "fast" working method/algorithm to solve the Number-of-paths-exercise we were given in my class />
So here's the task: Write an efficient java program "Paths" which solves the following task:
- Read input n ∈ N and give output a(n) which is the number of paths from (0,0) to (n,0) it is not allowed to go over the diagonal (m,m) and also not below the x-axis (m,0)
Here are the allowed steps: u = (1,1), U = (1,4), d = (1,−1), D = (1,−4) and H = (1,0) steps are performed in a two-dimensional-coordinate-system!
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;
So i was assigned to write a program that would print the answer to the system of two linear equation. the form of ax+by=c and dx+ey=f..I wrote this program, but it is incorrect since I tried it out on my terminal and I keep getting incorrect values.
import java.util.Scanner; public class Quest4 { public static void main(String[] args) { Scanner input = new Scanner(System.in);
This program deals with a variation of the geographic coordinate system with Greenwich at 51° 28' 38" N. The program will be adding the three values of one coordinate to the three values of the second coordinate. Though the maximum value for seconds and minutes is 59, the user can enter values greater than that number when prompted. The maximum degree is 360 for this assignment though the user can enter values greater than that number.
I have a beginning Java Program I have been working on that creates a number guessing program where the computer guesses a number that the user is thinking of within a certain range. I so far have the program below, but need getting rid of a few kinks/ adding features.
-First, I need to set it up so that the user will be prompted and give a range. It should run and produce something like this:
Welcome to this first-ever mind-guessing program!
Please pick a range (higher than 1 and no larger than 50): 32
You will choose a number between 1 and 32... and I will try to guess it.
With each of my guess, you will tell me whether I am too high (h or H), too low (l or L), match (m or M), or you want to quit (q or Q). My objective is to find the number using as few guesses as possible.
-Second, the game is supposed to give up and restart after failing the five, guesses, but for some reason, after it fails the fifth time, it prompts a fifth guess once again instead, then restarts after- I need to prevent this, so that it should look something like this:
My fourth guess is 17: h My guess is too high?
My fifth guess is 16: h *** I am unlucky this round. I give up.
Let's play!
My first guess is 10: etc..
import java.util.*; import java.lang.Math; public class numguessprac1 { // Declaring variables public static String input; public static int quit; public static int guess; public static int wins;
trying to write a program that takes a user inputted number and converts it to a binary number.
Here's what I have:
package com.java2novice.algos; import java.util.Scanner; public class Converter { static Scanner console = new Scanner(System.in); public void printBinaryFormat(int number){ int binary = console.nextInt();
I've been programming for years in a basic programming language, so doing something a bit more advance like this is quite challenging but I love it. where I've gone wrong here? I've been following a tutorial but I've decided to take what I've learned and make my own program but something seems to be wrong.
class Function{ public double abs(int num) { if (num > -1) { return num; } else { return -num;
[code]...
Basically trying to get the distance between to numbers but in a positive not negative number.
Netbeans do not detect any syntax errors, but I when I check the build it retuned areas they were a few; It's a simple program name 5 people, gade them then do final calulatoins it's called "grade tool.
heres the code
package gradingapplication; import java.util.Scanner; public class GradingApplication { public static double score(double score){ if(score >= 90){ System.out.println("A");
[code]...
~Problems~
1. It has no gui, I don't know java fx, is java groove used? awt is useful for creating spam bots in robot class, I know it's not very useful but it's so much fun.
I just started programming yesterday, and I have been making little programs to learn some algorithms and the syntax of java. I tried making a program that could convert metric units into the American system. Whenever I try to compile the code, it shows up as an "incompatible type" error. I know this is probably a very obvious answer to most of you, but I can't figure it out.
import java.util.Scanner; public class MetricToAmerican { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("fWhat measurement would you like to convert into US system? celsius, meter, or kilogram ");
Many classes calculate a final grade by using a weighted scoring system. For example, "Assignments" might be worth (weighted at) 40% of your final grade. To calculate the portion of the final grade contributed by the Assignments category, the teacher takes the average of all assignments in the category and multiplies it by the weight (40%). So if a student averaged 90% on all assignments, the teacher would take 40% of 90%, or 36 as the weighted average score for the assignment portion of the the final score. The teacher then calculates the weighted average score for each of the other categories (Quizzes, Midterm Exam, Final Exam, etc.), adds them all together to come up with the final score, and assigns a letter grade based on that score.
Write a Java program that allows the teacher to calculate the grade for a student.
Specification :
Prompt the user to enter the Student ID number, first name, last name, and the average score for each of the following categories:
I'm studying about arrays and I have some questions:
First, is there any difference between these two?
Java Code:
int x[] = new int[3]; int[] x = new int[3]; mh_sh_highlight_all('java');
It seems to me when I try them they do exactly the same, is that correct?
Second, more important question. If I want to make an int variable that refers to the index number of an array, how do I write? For example if we have
Java Code: String[] string = new String[10]; mh_sh_highlight_all('java');
And I want to have a variable "int n" that refers to an index number, so that if I set n = 5 then string[5] is selected. Note that the int n is NOT an array, but just a regular integer variable. How can I do that?
Explain anonymous objects with example clearly...i read some where anonymous objects advantage is saving memory...it is benificiable when there is only one time object usage in our program..i can't understand one time usage of object ....i know anonymous objects but i don't know in which context we use them in our programs...i did the anonymous object program with my own example but i can't differentiate this one with normal object..i'm providing my own example below
//anonymous object public class anonymous { int x=10; int y=25; void display() { System.out.println("anomymous");
I develop a finite element code at java. I am looking for efficiency solver and fast for large, sparse , symmetric and positive define matrices .
i used in jblas but i encounter in problem when the matrix has high condition number(ill condition number) and i get error for singular matrix while in mathematica i succeed to solve that system without problems...
Any good solver and fast solver package in java can i use for solving that system?
I`m trying to make a gradebook that uses random number generator to give the score, I also need to implement student numbers and sort everything with a total at the bottom. But I cant figure out how the bubblesorting works. This is my code so far:
package karakterbok; import static java.lang.Math; import java.util.Random; public class Karakterbok { public static void main(String[] args) { Random karakterer = new Random(); Random studid = new Random ();
I'm trying to make a program with two buttons... when you click the first a label shows a red square when you click the second it shows a green square... right now i have the imageicons as a comment because when they weren't a comment and i ran the program i saw nothing... the same thing happens when i add label2 to panel3.
Java Code:
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class GUI3{ public static void main(String[] args){ //frame JFrame frame = new JFrame("Test");