So I made a program that finds files and searches in them for key terms using the scanner class in java.util.*;
I've written it something like this:
Scanner filereader = new Scanner(System.in);
String filename = filereader.nextLine();
Scanner searcher = new Scanner(new File(filename));
The...
I wrote a class to sort Comparable elements in a list (ArrayList)
I have Student class that contains lastName, firstName, studentID, and tuitionFee as its instance variables.
At first I used mergeSort algorithm to write the Sorts class. It works when I add 1 student, still works with 2...
Q1. Write a function that accepts an array of integers and returns the second largest integer in the array. Return -1 if there is no second largest.
The signature of the function is
public class ID
{
public static void main(String[] args){ }
int f(int[ ] a) { }
}
Examples...
Hi,
I'm trying to create this output:
Input team 1's name:
Team 1
Input team 1's ranking:
90.4
etc.
For 8 teams.
This is what I have:
import java.util.Scanner;
public class Tournament {
public static void main(String args[]) {
System.out.println("Input team 1's name:")...
I recently had to get my computer rebooted using a fake operating system of XP due to a virus. But i can't get Java anymore! I can't validate my system as it requires that do proceed with the download. Is there anyway i can get it...?
Look am very interested by computer programming and now am learning The C++ language that's why i would like to ask anybody who can teach me java, just thank you
Hi,
I'm interested in pursuing a career in computational science and numerical computing and so on. I'm looking for some fairly general advice on how to direct my studies. I started learning programming in java, which I very much prefer to program in these days, having had some exposure to...
Hi, i would like to make a program which can detect my latency, if it's low then it would open a program and if it's high it'd do nothing, i'd also like to loop it so it tries every half an hour or so. Would this be possible? If so any advice on how to start I'm a bit rusty and have only tried...
Any one have any opinions on the differences between these two language (and their closeness to C)...
chroot posted about python being almost as complete as java interms of standard libs. I attended a presentation which seemed to verify that claim though you have to download some of the added...
Hello,
I need to write a method that adds an interger to a sorted array of integers. I'm using the following code to search for an interger in the array
private static int binarySearch(int[] list, int key,
int low, int high) {
while (low <=...
What I want to do is make a Voice chat room with administrative functions embedded in a website. i think the best way is to use Java, but I don't know anything about java.
i can't start from scratch and learn the language, because this is really important and I have less time.
i was hoping if...
Hi!
can you help for java homework?
i wrote but the program give error .
homework:
in 70 squares show to the hare and the tortoise race
i need to do this homework quickly!
thank you to help in advance!
Homework Statement
Write a program to calculate the Fahrenheit temperature from Celsius Temperature and vice Versa using appropriate menu.
2. The attempt at a solution
class prog
{
static void choice(String args[])
throws java.io.IOException
{
int choice=0;
System.out.print("Enter...
I'm trying to create a computer game (a platformer); currently I'm just trying to display a Polygon on the screen.
I have this class Charac, which contains a Polygon which defines its shape. If you display the bare Polygon, it'll put the shape at 0,0 on the screen. In order to move the...
Hi. I'm completely new to Java, but I'm taking a course at a local university. I was wondering if someone could help me with this.
I need to create a program that counts change (pennies, nickels, dimes, quarters).
I've only been taking the class for about a week and am still very...
I was wondering if I would be able to handle Intro to Java if I go in without any programing experience. I have experience in Calculus up to vector calculus and differential equations, electricity and magnetism physics course, but no programming. You guys think I can handle it?
Hello everyone. I was wondering if anyone has any suggestions.
Well I should be graduating this spring if every went to plan. But of course it didn't. I started going to school in 2003 as a Software Engineering major, got hurt took a year off for recovery, went back to school as a computer...
Is there any way to get color from RGB value?
for example
If I give some random RGB value like r=221 g=255 b=123 then how do I get the color associated this RGB value?
Thanks in advance.
Here's what I wrote , but there's no output.. It is suppose to read a line typed from the user and enter whatever the input was with the letter after the ones inputted. please help
import java.util.Scanner;
class ProblemS2 {
static Scanner sc=new Scanner(System.in);
public static...
I have a window here and I want it to close the whole program when the user clicks on File>>>Close. I just need to know waht to put inside the method to close the program. I mean, how do you terminate the program in java?
Hey, I'm working on a project with RoboJDE and java and I have a few quick questions.
What I'm supposed to do is write code so that the camera will find the coordinates of a swatch of color and move accordingly as the swatch changes positions. The robot is supposed to move from side to side...
I am creating a class that will transform a basic arithmetic expression from infix to postfix (Reverse Polish Notation (RPN)). Then after then, it will evaluate the postfix expression and give the answer.
I have having a little trouble with the operators (+,-,/,0*, and %). Like, I have to...
I may be taking control of the running of some seismology equipment, which is run via C code. I know very very little about C code. Would it be better for me to spend the time to thoughroughly learn C, or could it be possible for me to convert the software to Java. I have a pretty god...
Build a GUI to accept integers (when the ENTER key is depressed) into an arr
ay of 15 int; have a button called AVERAGE; when AVERAGE is selected, there
is a display of the count and the current average; have a button called CLEA
R; when CLEAR is selected, count is set to 0 and so are all...
Hey I'm new to this java stuff, I am taking my first class in it at the university of pittsburgh, and for my homework I need to write code to make a thing that will generate 10 random insults from a list of words. I have this outline to it and I was wondering if someone could help me fill in the...
I have to put a bunch of Java files (written in jGrasp) into one zipped folder and send it by email. The problem is that all programs work perfectly well when they are in an unzipped folder, but, when I convert folder into a ziped one, programs don't work. For example, I have user defined class...
Hello. I am writing a program, but I can't figure out how to do something. I want to do something like this:
Sample input:
abcdeft
01234567
asfgSample output:
The length of line 1 is: 6
The length of line 2 is: 7
The length of line 3 is: 3
How come when I exectue this program, I get the follwing error. Just to let you know, what i am trying to do is, check if ever digit in a number is a prime number.
import java.lang.Math;
public class PrimeNumbers
{
public static void main (String[] args)
{
int[] test = {546513, 77777...
Please, I am in desprate need of soemoen that knows java. I need to turn in an assigment in 2 hours and I am trying to figure out something that I don't udnerstad. We are currently doing input and output stuff. I am trying to figure out how to count the numerb of lines, words, and chars in a...
I have built a program to answer the follwoing question.
What is the smallest integer x >2006, such that x^7 and x terminate in the same five digits.
The answer I get is 75800. But when I punch in 75800 in the calculator, for some reason, the last 5 digits for this number and 75800^7 are...
Hello. I have an assignment that asks me to create a program that asks a customer of a store to type in their name, and an amount of money they spent. Then the program calculates a dicount they get according to the amount of money they spend. And print the discount to the screen.
But it...
In programming in Java I've frequently wanted to plot functions, meaning I've had to convert a double array of function values (and a corresponding array of their domain values) to integer arrays of coordinates to plot. I've always found this to be a pain in the neck, especially if you're trying...
the purpose of this thread is to be a placeholder for discussion about the performance of Java in Numerical Computations.
Started as a discussion between CRGreathouse and me about weather or not Java can be used effectively in doing computations.
The plan we have:
Phase 1:
Solve a...
I would like to be able to detect a click anywhere on the screen, not associated with any particular screen component, and in fact inside another program's window. I don't know if I can use the listener framework to do that--if I can, I don't understand how. Can I get a whole screen object to...
In Java, I am looking for a collection that will test if a given element is in a set, using the equal() method defined for the element. If it is in the set, I need the collection to give me the actual occurrence of the object from the set. Vector will do this for me via the indexOf() method...
I have only 1 day to work on my lab. Hope someone could help me as soon as possible.
My problem is I don't know how to count how many objects are created in a class.
The first assignment is write a Java class, Student, that has the following instance variables: name (String), age (int), gpa...
Greetings,
Does anyone know a website with a java applet for a Single or Double-slit experiment? I'd like to mess around with the variables to learn the intricacies of how it works.
Variables I'd like to mess with include:
slit width
slit thickness
slit distance from screen
incident...
I was curious if anyone knows if there are any methods to do the following in java.
I'm writing a terminal based program in java, and it will be doing incremental updates. I want to output to the terminal the percentage done, but to replace the last output. For example:
$>java jprog...
I'm trying to create this program that allows the user to create and manipulate trees. For example, a user might create a new tree with a node containing "words" as its data, then create nodes containing "nouns", "verbs", "adjectives", etc. as their data. The problem is I don't know how to...
I'm on ubuntu linux. I've installed java 1.5 but at the command line, when I type java -verion I get 1.4. So then I type: export PATH="/usr/lib/jdk1.5.0_06/bin/:$PATH". I type java -version and get 1.5, but then when i close the command prompt and open a new one, it's back to java 1.4. Any help...
I'm interested in learning foreign languages. I plan maybe to study japanese linquistics in college. I'm learning spanish and japanese, but more japanese for now.
I signed up for a yahoo account on yahoo chat on video games, but I keep getting very strange errors and it won't let me type in...
Hello all. I have never taken a programming class, but this next semester I am taking two. One teaches you Java, and the other is C. Will it be hard to learn both at the same time. I am very dettermined, and a very hard studier and hard worker. Has anyone else here learned two languages at...
Hi,
I just updated to 5.0 and changed the java version from the java preferences as instructed in the installation instructions. However, from the terminal if I type java -version it shows that the 1.4 is still the default. Can someone tell me how to set 5.0 as the default from the terminal...
I want to lear Java MIDP which can allow us to create an mobile applications . Did anyone know where I can find the tutorial for free at the Internet ?
:redface: Is there a way to convert a character representation of an integer into an integer (with integer representation :rolleyes:)?
*for example (I'll add 8 to a certain digit in an integer),
String nmbr; //where I enter a number
int pst; //an integer representing the position of that...
Java's "Scanner"
Hello,
I own a Macintosh and was trying to write a simple Java program for one of my classes. However, I quickly discovered that it appeared that the Mac does not have the Scanner ability. I get an error on the "import java.util.Scanner" line saying
"cannot find symbol...