Homework Statement
We must make a class used to evaluate a polynomial function of x. My problem is I am getting an array out of bounds exception when I run the main, and I can't figure out why.
If you could help me figure out this out of bounds exception it would be very appreciated thank you...
Homework Statement
Write a program that takes a file name as argument and counts the number of words and the number of characters (without spaces) in the document.
Homework Equations
The Attempt at a Solution
How exactly should my program take a .txt file as an argument? Do I simply:
String...
Homework Statement
So I'm trying to create a method in java. The method is supposed to take a string and use the rot13 method to hide the message. That is, it takes each letter and places it forward 13 letters, so a becomes n, b becomes o, etc.
Now I'm pretty sure this method is at least...
Homework Statement
My class is required to write the Java source code for a 15 Puzzle program as an end of the year assignment. http://en.wikipedia.org/wiki/15_puzzle" is a link to what the 15 Puzzle is, for those who aren't familiar with its name.
The assignment is split into two parts...
Homework Statement
I've implemented RSA and just need to print some stats and write to files.Homework Equations
My solution works fine when I provide an input file, however, if I let it read from standard input there is no output written to either of my output files. Reading works regardless. I...
Homework Statement
Homework Equations
The Attempt at a Solution
public class Caesar
{
public static void main(String[] args)
{
int k = Integer.parseInt(args[0]);
char c;
String strMsg = StdIn.readString();
System.out.print("Encrypted sentence is: " );
for (int i = 0; i <...
Hello, everyone.
I've been learning how to code for a bit. I picked Python because I figured I'd be able to skip the issues I would otherwise have with syntax and focus more on the programming aspect of it.
Soon, though, I'm going to be ready to dive into one of the other languages with a...
Hey guys, there is this problem from my school in which I'm having troubles..
This code is from past school lab (assignment) assigned a loong time ago
And I figured I would go back to it, to practice my coding skill, since I wasn't able to solve it back then.
So here is the code...
hey - any idea why the following bit of code only stores one of my answers, and not both in an array like i was hoping?
thanks
1 /*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5 package gose1b;
6
7 import...
I have input from the user which is the last name, sent to be set as the last name for my object in my setLasttName method.
public void setLastName(String lName) throws IllegalArgumentException {
if (lName.matches("[a-zA-z'-]")) {
this.lastName = lName; }
else {...
First i create simple claculator.but now I am trying to change it to RPN calculator by using stack.Can some one help me((especially where to use pop method) because I don't know a lot about stack.here is my codes so far.
import java.awt.event.*;
import javax.swing.*;
import...
im a bit confused - please help - I am a complete beginner!
I have several classes, within which are several attributes defined and declared.
The assocation between some of these classes are aggregation, and between others is compostion.
Take the example of person and car being and...
Homework Statement
I need to create a loop that asks the user to input double numbers into an array. The number of elements in the array is not predefined; the user will continue to enter numbers as long as they wish until a NEGATIVE number is entered, at which point the control will exit...
Homework Statement
Write a method isPalindrome that accepts a string as argument and returns true or false
indicating if the string is a palindrome or not. A palindrome is string that can be read the same way forward and backward. Your method must handle upper and lower case characters (the...
I have a program which uses a keyboard listener and moves a character in the program when the user places a key. However when the user let's go of the key the character keeps going a few more steps. I think what is happening is that I use a while loop and make it wait a few seconds in order to...
here is
import java.util.*;
public class oddNumbers
{
public static void main(String[] args){
System.out.println("enter two number");
Scanner kb=new Scanner(System .in);
int number=kb.nextInt();
int number2=kb.nextInt();
int s=number2/2;
String decision...
Something like this:
http://www.falstad.com/vector/
Particularly concerned with particle motions. I don't know how to begin with using physics equations for creating simple java visual simulations. Can be 2D or 3D.
I know some java programming so I'd prefer code examples than...
Im having trouble with a method that finds the height of the closest leaf. What i have just counts all of the leafs. would i have to separate the recursive calls into two conditional statements to check each one independently? any help or suggestions would be appreciated
this is my method...
Homework Statement
http://pastebin.com/7ehbwkvE
expires in 1 month...
the problem statement is very vague... we are given this code of an infinite loop, and need to fix the problem that it poses by either using a correct while loop or a for loop.
Homework Equations
The Attempt at a...
"Hello World" Java issue!
I've been following Stanford's on line lecture series Programming Methodology and have run into an issue while trying my first Hello World program.
I'm using the Eclipse editor and have attached the acm JAR library. When I try to run the file, I get an error that...
I'm having to create a temperature class for one of my assignments, were just getting into oop. Basically we just create a few constructors, accessor and mutator methods. The mutator methods are where celsius-farenheit conversions are. And we need to make an equals method which I know how to do...
System Requirements:
Congratulations! Your software company BestSolutions Ltd has won the contract to
develop a new hotel reservation system for the L4 chain of hotels (check out
l4hotels.com! ...or something similar). At present the chain consists of a 5-star, 4-star and
3-star hotel but the...
I am having the user enter a bunch of strings and when the user wants to stop entering them I want him to use control z to stop the input. The only problem is I can't seem to figure how to make that happen, does anyone have any suggestions?
I am writing a program using JOptionPane that asks the user to input a decimal number, and then outputs the decimal number in binary. The program then asks the user if they would like to convert another decimal to enter y/n (with case being irrelevant). I was able to ask the user for the decimal...
Homework Statement
Write a program that takes a command line argument integer M and prints all the positive integers that are powers of 2 and less than or equal to M.
Homework Equations
for loops; if conditional.
The Attempt at a Solution
public class PowersOfTwo
{
public...
We learned of accessor and mutator methods in class recently. But even after a few labs implementing the two types, I still am having trouble understanding when to use/implement either one.
I don't understand why you'd need two different method types. Couldn't you set any method with a void...
..so, we have been assigned a homework to print a certain ASCII art using only loops and methods. We can also use the built-in math methods such as the exponential one and whatnot.
Basically, we have been asked to print an increasing loop that goes as follows:
*
***...
I'm trying to make a program that prompts a user to enter a binary number and then converts the string into integers by using Integer.parseInt. Right now though, I'm having trouble with tokenizing the string. My code works when I use the predefined variable temp but not when I enter the same...
Hi :)
I'm taking my first java course. I took two C++ courses last year, and I understand OOP pretty decently, but I cannot get this java program to work! And I'm beginning to get really frustrated because I can't find my mistake.
This is my class file:
package studentsjav;
__________...
I have Netbeans IDE 6.9.1 installed on my computer,and I was trying to enter the following code in a new project:
01 public class Hello
02 {
03 // 是程序的起点,所有程序由此开始运行
04 public static void main(String args[])
05 {
06 // 此语句表示向屏幕上打印"Hello World !"字符串
07...
Homework Statement
Basically, I am assigned to implement my own iterator using a Doubly Linked List. The methods, of course, are hasNext(), next(), and remove(). The one that is giving me the most grief is the remove() method.
Homework Equations
The Attempt at a Solution
The...
I'm an experienced C++ programmer looking to learn Java SE 7. Because of the similarities of the language, you'd think there would be a tutorial out there suited for such people but I'm having trouble finding one. I've looked at a couple of Java tutorials that are tailored to C++ programmers...
For my class I need to make a "Guessing Game" Program. Basically you just pick a number between 1-1000. It tells you if you are too high, too low, or correct. If your too high or low you guess again until you get it right. When you get it right it is supposed to tell you how many tries it took...
In class the other day, my professor had written this as part of the lecture notes:
Thus, this definition was mentioned as part of methods. He then went on to show an example of this as in the following:
public class Dog {
private Collar _ collar;
public Dog(Collar collar) {...
I want to start learning Java programming,by myself. I got some PDF books. In the introduction, it talks about UML, but I find it complicated. I want to know whether it is a must to read the theory part, or I can just start on the practical part.
Okay.
So, I'm taking up a beginning Java course in college and we have been assigned a rather simple (?) homework.
We have to code a program that prints a statement a thousand times, but without the use of loops, only methods. I know I can create a method that contains a number of the...
Hello everyone. I want explanation of the working of 'this' keyword in java. I read articles but couldn't understand. Please help me here. I don't understand what objects and variables they are talking about. Also give me an example of what object, variable, instance variable is.
Box(double...
Homework Statement
Write an application that inputs ten numbers from the user, each number can be between 10 and 100, inclusive. As each number is read in determine if it is a number already entered. If it is a duplicate move on to the next number, if it is unique store the number in the...
im having a little trouble getting started with this. it is for an array of strings.
would i do insertion sort the same was as if it was an array of ints or doubles but use the compareTo method to see if i should switch two elements?
this is my attempt so far, it won't compile due to the...
Hello, I am just starting to learn Java. I have a small file that needs reading in, line by line, with different arguments. Such a line looks like this:
123 Midterm .25 100
456 TakehomeExam .25 200
0 Quiz03 .10 25
1 Final .40 100
I need to read these in as separate variables. I...
CAN SOMEONE PLEASE explain the "this." keyword in java to me?!
"the this keyword can be used to refer to the calling object or used inside one constructor to invoke another in its own class.
I understand how it invokes another constructor. But i do not understand why i keep seeing this code...
I'm trying to create a program that derives a class named Student from the class Person, and then I'll test everything in the main program in TestStudent. What I'm having trouble with at the moment, is calling the methods correctly. Whenever I try to call a method in the main program, I get this...
supposed to reverse an array of strings recursively. this is in a class that has an array object.
i came up with what's below. but it reverses the array in a weird order. the array is a 5 element array, the elements are {hello, how, are you, ?}. i passed in the object and after printed out...
Hello everyone. My task here is to construct my own linked list. The outer class is SLList and the inner class is Node. The problem that I seem to be having is when I try to use the fields of the outer class in the inner class, I am getting "cannot make static reference to the non-static field."...
okay so i have my program basically done, i just have one problem and it has to do with an enumerate data type i created
public enum PaintColor {RED, BLACK, WHITE, BLUE, GREEN, OTHER};
in my class that is UsedCars
im tracking attributes of these objects [used cars]
now...on my TestUsedCars...
I've been working on this and I can't figure out why, exactly, it's not working properly. I can reserve a seat 4A but when I try to reserve seat 6A, the output includes a line of string that says "The seat you requested is unavailable. Please make another selection." yet it still let's me make...