Java Program That Draws A Spiral?
Nov 7, 2014
I'm trying to make a java program that draws a spiral like this: [URL] ....
It was use a draw method to draw it in a specific way. What I have in my code so far is:
for (int i=0; i<line.length; i++) {
line[i] = new int[4];
line[0].x = 0; line[0].y = 0;
line[1].x = 0; line[1].y = boxSize;
line[2].x = boxSize;line[2].y = boxSize;
line[3].x = boxSize;line[3].y = 0;
It would be made through a 2d array and the values for how big the lines are would be stored in another file called line_details.txt which contains these values 0 200 1 175. So how would I implement this stuff into a Java code?
View Replies
ADVERTISEMENT
Oct 1, 2014
Is my code right for this pseudocode:
<Declaration of the array for storing random integers and other necessary variables and / or constants. >
private int numbers;
private int max;
private int[] integer;
private Random generator;
public integer ( int n, int m )
[code]....
I need to create a program that draws random numbers and stores them in an array. How many numbers to be drawn is dependent on the array length, which is a parameter in the class constructor. (The entire array to be filled!) The program shall, however, just save the figures are not drawn already. (Ie, the array must contain only one instance of each numeral.) All figures drawn should be in the range of 100 to 1000, both limits included. These limits are defined as named constants. When all the numbers are generated and stored in the array, the program should find the largest, smallest and average value of the numbers in the array. In addition, it should find the value closest gjennomnstittetsverdien.
View Replies
View Related
Aug 3, 2014
I am working on a problem where i have to create a 2d array with given input of the dimensions (odd number) of array, along with a number within the array and to then print out all of the numbers surrounding that number.
Anyway, i am working on simply making the spiral, which should look like the one below.
n = 3
7 8 9
6 1 2
5 4 3
where the 1 always starts in the center with the 2 going to the right, 3 down, then left etc. etc. I was able to create the code by starting on the outer edges rather than the center and working my way to the middle, however my code always starts from the top left and goes around to the center where it needs to start from the top right. I am having trouble altering my code to meet this criteria. This is what i have thus far.
import java.io.*;
public class Spiral
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of elements : ");
int n=Integer.parseInt(br.readLine());
[Code] .....
View Replies
View Related
Oct 5, 2014
The following class is part of a homework assignment:
package event;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import model.Model;
import shapes.Rectangle;
import shapes.Shape;
[Code] .....
I have to implement the methods for what is happening if on some panel the action selected are Remove/Move/Change/Resize (Draw is already implemented).
The Applet in question draws ovals or rectangles on the screen and you can change the fill-color and outline-color of the shape. All this works already. I have dabbled with the move-method, but am not going anywhere.
View Replies
View Related
Apr 16, 2014
Have written a program to open Excel sheet from java program.Below line works fine.
Process p = Runtime.getRuntime().exec(new String[]{""C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE"","C:UsersRASHPA~ 1.ORAAppDataLocalTempExport_xl420314062726 9379706.xls"});
But below code gives error i.e. Executable name has embedded quote, split the arguments
String path = "C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE";
String file = "C:UsersRASHPA~1.ORAAppDataLocalTempEx port_xl4203140627269379706.xls";
Process p = Runtime.getRuntime().exec(new String[]{"""+path+""" + ","+file});
I am using java 1.6.
View Replies
View Related
Feb 20, 2014
I'm creating a program that will compile and run another java program:Lets say I have a program in directory
D:HelloWorldsrc
and compiled program will be in
D:HelloWorldin
inside src and bin is a folder hello (that's a package)
package hello;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Hello World");
}
}
This program will be run by another program (that's the program that I am creating).Here is the code of my program:
package runnercompiler;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class RunnerCompiler {
[code]....
View Replies
View Related
Oct 24, 2014
I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;
[Code] ....
View Replies
View Related
Dec 22, 2014
How to send sms to mobile using java program. I have tried lot of examples, I didn't get perfect example ?
View Replies
View Related
Jan 30, 2014
I want to develop an simple application using java for a simple porgram for the addition of two numbers.
View Replies
View Related
Jun 26, 2014
How to find if JVM is 32 or 64 bit from Java program....
View Replies
View Related
Jan 18, 2015
I have to read two pair of words as array from keyboard and then check corresponding words are anagram are not. If they are print 1 otherwise 0. Total number of words in the pair cannot exceed 100, the word length cannot exceed 100 and only lower case letters are allowed.My code is the following:
import java.util.Scanner;
import java.util.Arrays;
class MyClass {
public static void main(String[] args) {
[code]....
How can I improve the code?
View Replies
View Related
Apr 18, 2010
I have spent quite a few hours trying to follow an API on how to use Actions in a java program.
I have 3 JButtons and have just added a JMenu. What I want to do is to add an ACTION so that the JMenu performs the same function as the JButtons. (i.e. they both do the same thing).
I have tried to copy and follow the example from the API forum.
How to Use Actions (The Java > Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)
The first error I get in compiling is on the following line:
Action loadFile = new LOADFILE();
However, I get the following error message:
softeng2final2.java:49: cannot find symbol
symbol : class LOADFILE
location: class softeng2final2
Action loadFile = new LOADFILE();
[Code] .....
View Replies
View Related
Oct 24, 2014
I'm new to this so take it easy on my code!! It compiles but its not giving me the correct outputs and I can't figure out why. Two words or phrases in English are anagrams if their letters (and only their letters), rearranged, are the same. We assume that upper and lower case are indistinguishable, and punctuation and spaces don't count. Some examples and non-examples:
* The eyes / they see (yes)
* moo / mo (no)
* Clint Eastwood / Old west Action! (yes)
* Dormitory / Dirty Room (yes)
For more examples, see here.
Your job for this assignment is to solve a slight variant of the traditional anagram problem called superanagram. Here you are to write a two class application that reads in two words or phrases from the keyboard, and then judges if the first phrase is an anagram of some of the letters in the second phrase. Here are some examples:
* mo / moo (yes)
* mo / mOO (yes - capitalization doesn't matter)
* moo / mo (no - first phrase is NOT an anagram of some (or all) of letters of second)
* rip / ziPPer (yes)
* abc / aabc (yes)
* aabc / abcde (no - too few a's in the second string)
* flipper / rip (no)
* Clint Eastwood / Old west Action! (yes - the two can have exactly the same letters)
You must use the Scanner class to read in the input strings. Use the nextLine() Scanner method, rather than next(), since spaces may be present in the two phrases that are submitted.Your program should either print YES, if the superanagram relationship is satisfied, or NO, if it isn't.
The classes MUST be called SuperAnTester, and SuperAnagram
* use the String methods toLowerCase() and (possibly) toCharArray(). The former takes all letters in a String and changes them to lower case; the latter converts a String into an array of characters. Also, this assignment is - of course - about characters and character matching. For some useful background on characters and how to work with them, watch the movies in the textbook at the ends of section 4.1 and 7.1.
* Very important: suppose you have two arrays of characters such that the first is purported to be an embedded anagram of the second, in the sense we've described above. How can you tell? The single most important thing to do, before you write a single line of code, is to work out a paper and pencil algorithm that distinguishes between superanagrams and non-superanagrams.
* Your classes must be commented! In particular, each method must have a one line comment just below the header line, which tells what the method is supposed to do.
* Algorithm Idea #1: make a scoreboard for the letters a to z. Every time you encounter a letter in the second String, up its count by 1; Then, every time you encounter a letter in the first String, lower its count by 1. Accept if the scoreboard ends up with all entries >= 0. (of course make sure you understand why this is - use pencil and paper to convince yourself!!).
* Algorithm Idea #2: convert strings to arrays. March down first array (representing the first string). When you encounter a letter, look for it in the second array. If you find it, blank out the occurrence in the second array; if you don't find it - it's not a super anagram. When you're all done, you've got a superanagram if your search in the second array never goes bad.
public class SuperAnagram{
private String wordOne;
private String wordTwo;
private char firstArray[];
private char secondArray[];
[code]....
View Replies
View Related
Oct 19, 2014
how to print from bluej onto actual paper? how to do the formatting and configuration etc.
View Replies
View Related
Mar 11, 2014
This code is for a GUI Java program that is supposed to convert back and fourth between two numbering systems. For example, binary to decimal or decimal to binary. I have created methods for some of the conversions however, I could successfully develop a method to convert from hex to binary. If you plan to run it to see what happens to the current method that I made please know that in the GUI the north end from left to right is as follows.
The textfield is for user entry of any type of data. The first combobox is for the user specifying to the program what type of data he or she entered. The second combobox is for the user to choose what he wants that data converted to. The button is to convert it. The south side has a textarea that gives out the results. Please note that only some of the conversions work so far. There are comments in the code to label which methods do what converisons. Need to find a method that will convert from hex to binary, what is wrong with the current method.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
[Code] .....
View Replies
View Related
Nov 9, 2014
I have been trying to make a football league table in java based on text input and output. I want to to know if i have done task 1 right if not could you
Task 1. Design and implement classes SportsClub (abstract class), FootballClub.Classes should include appropriate methods and hold information about name of the club,its location and various statistics about the club. FootballClub should include statistics such as how many wins, draws and defeats an instance of it has achieved in the season, the number of goals received and scored. The number of points that a club currently has, and number of matches played.
Task 2. Implement a class PremierLeagueManager which extends interface LeagueManager. PremierLeagueManager class maintains a number of football clubs which play in the premier league. The class should create a menu based on text input and give the user the choice of:
• Create a new football club and add it in the premier league.
• Delete (relegate) an existing football club from the premier league.
• Display the various statistics for a selected club.
• Display the Premier League Table
Here is my code for Task 1:
public abstract class SportsClub {
int position;
String name;
int points;
int wins;
int defeats;
int draws;
int totalMatches;
[code]....
View Replies
View Related
May 28, 2014
I have a JSP and Java program which will read data from Excel and add them dynamically to create table.My requirement is i should able to edit the columns what ever the data that was fetched from Excel and export those contents to another excel file.This should happen on clicking a button, i mean to exporting the contents of the table.
View Replies
View Related
Mar 16, 2014
i have 2 java program the first java program is main menu of my program. the 2nd is Calculator.
#1 Program: Main Menu
import java.awt.event.ActionListener;
import java.awt.event.*;
import java.awt.*;
[Code].....
in the main menu there is a Jbuttons. is there a way to run the #2 program: Calculator when the 1st Jbutton(Calculator button) clicked ?
View Replies
View Related
Dec 26, 2014
I wanted to build an mp3 player as a Java project. One crucial part of the project involves being able to play an mp3 fie. I am not able to find the right api (if one exists) and am not able to find a suitable answer when searching on the web. A simple code snippet illustrating the playing of mp3 file using Java program. Also, I am using Eclipse IDE and how to import files if any importing of files is required.
View Replies
View Related
Sep 26, 2014
i have a similar problem but what i need to do is to detect an exused absent of which in my notepad is represented by 00 and 0 being an unexcused absent, anyway if a student has an excused absent example a quiz for that day will be deducted from the total quizzes example if i was the teacher and had 2 quizzes of 10 items each and she was absent in one of the quizes instead of let say her score was 9 on the first quiz it should go 9/10 and if it was an unexcused absent 9+0/20 anyway this is my java code and notepad example
import java.io.*;
import java.util.*;
import java.lang.*;
public class GradingSystem {
public static void main (String[] args) throws FileNotFoundException
[code]...
View Replies
View Related
Apr 17, 2014
Here if we give input from a text file from a disk and (a[b+c{d}]-v) is true and{a-(b]} is false but i get some syntax errors ...
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Stack;
public class Syste {
private static String expr;
[code]....
View Replies
View Related
Mar 2, 2014
I've decided to go back to basics and start using pseudocode--but i want to see if my logic is correct.so here's the first program:each delegate to a certain conference must wear a tag showing their name and the organization they represent as shown below:
######################
#### Annual Conference #####
######################
##NAME: ##
######################
##ORGANIZATION: ##
######################
write a class called TagMaker that prints out tags. supply methods to (a) set the name (b) set the organization (c) print tag with the name and organization (d) clear the name and organization (e) print a blank tag. then write a TagTester class to test the TagMaker class. so this is the pseudo code (or logic) that i've come up with for the program:
TagMaker main class:
-Prompt user to enter in first and last name, as well as their organization.
-Read user input for the name and organization.
-Return user input.
-Write conference tag showing the person's information.
-Clear information.
-Print blank tag.
1. i assume i would have to import a few java libraries.
Java Code: java.util.Scanner mh_sh_highlight_all('java'); and Java Code: java.io.*; mh_sh_highlight_all('java');
2. afterwards i would declare the instance variables (private, i assume). static too? so for example: Java Code: private static string firstName mh_sh_highlight_all('java');
3. i'm not sure if this program requires a constructor...being that i'm supposed to clear the program at the end anyway.
4. i create a public class declaring my input variable. example: Java Code: String first = firstName.nextLine(); mh_sh_highlight_all('java');
5. so i then i have to create methods that get/set the user input.
getter/setter example:
Java Code:
public String getFirst(){
return first;
}
public void setFirst(){
this.first = new first;
} mh_sh_highlight_all('java');
6. to print out both tags, would i write most of the code as part of a loop and make an "if" statement where the user input is valid, it prints out a tag with information, and another "if" statement that would automatically clear the buffer?
7. last i would create a tester class that would primarily be responsible for the program's output.
View Replies
View Related
Sep 2, 2014
I've been having trouble with this code for about a week and I've finally got it down to one error. Here is the code:
import java.util.Scanner;
public class Triangle {
public static void main (String[] args) {
Scanner Console = new Scanner(System.in);
System.out.print("Please enter the three lengths of your Triangle: ");
double a = console.nextDouble();
[Code] ....
And here is the error:
Triangle.java:30: error: class, interface, or enum expected
} // End class
^
1 error
View Replies
View Related
Jan 27, 2015
I wrote a small Java program called ( "Hello,World ).My next step will be to install this program as an app on my smartphone and I wonder what is involved ?
View Replies
View Related
Aug 15, 2014
im wanting to create a console gui that opens with my program game and people can type stuff in it to run commands as well as a debug option to show when errors happen and have a command to list all availble command.
View Replies
View Related
Apr 9, 2014
Write a java program that uses a While loop and persistent output to count down from 33 to 0 by threes, and put each value on a separate line, also do this in for loop.
View Replies
View Related