Could Not Find Proper Position In Print
Aug 3, 2014
So I need to print out the table of conversions from kilogram to pound and from pounds to kilograms. I think I have done a while loop correctly, but it is hard to actually check it since I do not have proper output format. I have tried also %4.2f format option however could not find the proper position in the print.
public static void main (String[] args){
System.out.printf("%10s%10s | %10s%10s
", "Kilograms", "Pounds",
"Kilograms", "Pounds");
System.out.println("---------------------------------------------");
[code]....
View Replies
ADVERTISEMENT
Sep 23, 2014
I am trying to take physical print out for bill, But i am receiving some problems:
Java Code:
import java.awt.Color;
import java.awt.print.PrinterException;
import java.util.ArrayList;
import javax.print.attribute.AttributeSet;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
public class Printme {
[Code] .....
But My Output is
What i have to do / learn to get the proper bill format ....
View Replies
View Related
May 4, 2014
I have included split() to put a string read from a given file into indexed array. Looking for a word position (not char position number in addition to the line number I have already written. Line number works fine, however word position isn't quite right.Below is my code:
import java.io.*;
public class Word implements Comparable, TreeComparable{
String word;
int count;
int wordpos;
ObjectList lines;
private SuperOutput so;
[code]....
View Replies
View Related
Oct 5, 2014
An array which contain a list of names. I let for a user input and I use that to search through the array. For example lets say the string name "Christian" is stored inside the names array and the user types in Chri, the program looks in the array and finds a name that contains Chri and prints them out. How do I go about doing this?
View Replies
View Related
Nov 25, 2014
The program is just a simple one to print grades using only methods. The problem is Im trying to use a returned value in another method but the compiler keeps telling me it cannot find the symbol "mark". the problem areas are marked in blue. I am basically trying to input a value into the keyboard and then use it in another method.
public static void main(String[] args) {
printTitle();
enterMark();
gradeCalculator(mark);
printGrade();
[Code] .....
View Replies
View Related
Aug 17, 2014
I am trying to run a simple program that connects to a mysql database and prints out some fields. I am using Eclipse.
THe problem I am having is on the following line of code.
Class.forName("com.mysql.jdbc.Driver");
I get an error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
[Code] ....
I have done some research and from what I have found is that I need to alter the class path to pick up the driver. When I downloaded the .msi I ran it and then the program closed. Where the files are ??? How to locate and import the file so I need to get my program to run?
I have included all the of the source code below.
package mySQLConnect;
import java.sql.*;
public class Connect {
// JDBC Driver name and database URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String BD_URL = "jdbc:mysql://localhost/sstbde";
[Code] .....
View Replies
View Related
Apr 22, 2014
why am I not getting a proper shape of "Leftarrow"? The result should look like the following (the system draws the arrow abnormally, so the beginning should a real ARROW:
*
* *
* *
* * * * * * * * *
* *
* *
*
here is the class:
Java Code: public class LeftArrow extends ShapeBase {
private int lengthOfTail;
private int widthOfArrowHead;
[Code]....
View Replies
View Related
Feb 16, 2015
When I run this (entering 12 for both questions) I get this error:
java.lang.ArrayIndexOutOfBoundsException: 12
at MathTablesTwo.main(MathTablesTwo.java:22)
Also, what would be the proper way to organize my code into blocks?
import java.util.Scanner;
public class MathTablesTwo {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
[code]....
View Replies
View Related
Dec 2, 2014
I have a signed certificate from Entrust which I used to sign a DeploymentRuleSet.xml file. I placed the DeploymentRuleSet.jar in the proper location C:WindowsSunJavaDeployment, afterward the java control panel's security tab shows a link to "show the active deployment rule set" which did not exist prior to coping the file to the directory. When I click on the link a new window opens and says "Rule Set not found" ....
View Replies
View Related
Jul 18, 2014
Below is a method that is suppose to insert a value inside a stack based on the index. I thought it would be easier to copy the value, if any, that was in the index into the variable holder and replace it with the input value. After in which it would copy the holder value and place it at the top of the stack. (topOfStack variable is what the holder is copying too.)
public void pushExact (int index, String input) {
String holder = "";
if (maxSize == 0) {
theStack[topOfStack] = input;
topOfStack++;
} else if (topOfStack + 1 < maxSize) {
for (int n= maxSize - 1;n >= 0;n--) {
[Code] ....
View Replies
View Related
Oct 5, 2014
why the output is not giving the proper result? Is this a semantic error?
public class Programming1Practice {
/* testing out instantiation and object oriented programming */
public static class staticValues {
[Code]....
View Replies
View Related
Jan 28, 2015
Okay so I need to be able to read a file and then be able to find the longest sequence of increasing numbers.
So if the file was this, (this is Ass1Q2_test4.txt)
97 47 56 36 60 31 57 54 12 55
35 57 41 13 82 80 71 93 31 62
89 36 98 75 91 46 95 53 37 99
25 45 26 17 15 82 80 73 96 17
75 22 63 96 96 36 64 31 99 86
12 80 42 74 54 14 93 17 14 55
14 15 20 71 34 50 22 60 32 41
90 69 44 52 54 73 20 12 55 52
39 33 25 31 76 45 44 84 90 52
94 35 55 24 41 63 87 93 79 24
the output should be,
(5,0) with cost 12
(6,0) with cost 14
(6,1) with cost 15
(6,2) with cost 20
(7,2) with cost 44
(7,3) with cost 52
(7,4) with cost 54
(6,3) with cost 71
(5,3) with cost 74
(4,3) with cost 96
Greatest path is of length 10.
Now, the code that I have works, kind of. Instead of recurring several times at each point, it only recurs once.
So say I'm looking at (1,1). With (1,1) being 57. The area around it looks like this.
97 47 56
35 57 41
89 36 98
Now when I look at it, there are several paths it can take. It can go 57, 97 or 57, 89 or 57, 98. However, I'm pretty sure that it just uses the first one that corresponds with the first if statement that is valid. So I start checking north of the value, then northeast, then east, then southeast, which at southeast is where I find my first greater than value. After it finds it's first valid number, it then continues from that number, instead of checking if there are other longer paths stemming from the original value.
In conjunction with that, you can see that the printout just returns all paths from each value. Which isn't what I want. I need a way to store the longest current path, then check each path after to see if it's longer. If it is, it's replaced, if not, it stays the same.
I've also attached Ass1Q2_test4.txt
import java.util.*;
import java.io.*;
public class MaxIncreasingSub {
[Code].....
View Replies
View Related
Nov 27, 2014
You are given 2 files - "testcase.txt" and "validwords.txt".In testcase.txt, the sentences are written without any space inbetween/for ex: this is a sentence which looks ambigous.You are to insert a space at the proper place by breaking the sentence into correct words, ex o/p: this is a sentence which looks ambigous.validwords.txt contains all valid words (as 1 word per line). If you find a word that does not match, replace it with ####. After correcting
View Replies
View Related
Feb 25, 2014
Here's the code: it's while loop inside a for loop to determine the proper length of a variable:
for (int i = 0; i < num; i++) {
horse[i]=new thoroughbred();
boolean propernamelength = false;
while (propernamelength==false){
String name = entry.getUserInput("Enter the name of horse "
[code]....
I was just wondering what was going on here -- I've initialized the variable, so why do I get this message? (actually the carat was under the variable name inside the parentheses.
View Replies
View Related
Jun 19, 2014
How can I set a new Mouse position ?
Is there any class that represent the Mouse ...
The cursor class is without this ability ...
View Replies
View Related
Jul 8, 2014
I have to insert certain lines of html code in already existing file of html using java.I have to add certain things in head and some things in body.
View Replies
View Related
Nov 4, 2014
I am developing an application where blind person can interact with computer i have completed the part where computer responds as per command given by user.The part where i am stuck is i want to give voice feedback as user moves the curser for example if mouse is on d drive then user should get feedback that its d drive....i want to do it for whole windows ...
View Replies
View Related
Jun 18, 2014
How do i set a random font in java and random position on screen. I've got random color but cannot get the font and position to change except for two times.
import javax.swing.*;
import java.awt.*;
import java.util.Random;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class JChangeSizeAndColor extends JPanel implements ActionListener {
private Random generator;
[code]....
View Replies
View Related
Jun 4, 2014
I can't recolate and align the button, the circle or the line where i want it to on the canvas. I want to be able to move the line where i want it, now it seems like all objects are stuck in the middle of the scene or canvas.
package application;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
[Code] ....
View Replies
View Related
Nov 6, 2014
I need to make a simple applet, but I'm stuck with something. This is how my applet should look:
And this is how that part looks in my applet:
What I've done until now is create one JPanel which includes two other JPanels.. The first one contains only the JTextArea you can see, and the other one includes the other elements.
I just need to make the JTextArea taller, like in the example, so everything comes into place...
View Replies
View Related
Oct 18, 2014
I am trying to draw add flowers on a graphics window. I can do this just fine, however the position starts from the far left and goes to the far right. I would like to position the 8 flowers in the center of the screen but can't seem to get the right formula to do so. Here is what I have so far to draw the flower, which is simply a GOval nothing complex:
Java Code:
box.flowers=8;
for (int xpos1 = 10; xpos1 < getWidth() - 40; xpos1 += getWidth() / box.flowers) {
box.drawFlowers(xpos1, 400);
} mh_sh_highlight_all('java');
The box size of the window is 800 by 600. Ideally I would like to place x amount of flowers spread across the middle of the screen. How might I do this???
View Replies
View Related
Jul 14, 2014
This is my code:
JDialog dialog = new JDialog();
dialog.setSize(400, 150);
dialog.setTitle("Input dialog");
dialog.add( new JLabel("simtime(min)") );
dialog.add( new JLabel("interval(sec)") );
dialog.setVisible(true);
The problem is that the two lables replace each other.How to position them where we want?
View Replies
View Related
Feb 23, 2015
I am developing a form with ComboBox as a subject (the user can choose one from the list , or type one) and TextArea where the user can write his notes (attached a picture). The user using a virtual keyboard (touch) to enter any characters.
I am using the append method to append the next Char to the TextInputControl class (both Combo and TextArea Inherit from it). When I try to deletePreviousChar() in the TextArea it works, but in ComboBox it fails
I put some System.out.println() to see what is the problem and it seems that with the ComboBox the class is loosing the Caret position after every action
Here is my code: (Look it also as a attached picture)
public void changed(ObservableValue<? extends String> observable,
String oldVal, String newVal) {
if (newVal != null) {
if (lastNodeInFocus instanceof TextArea) {
switch (newVal) {
[Code] ....
Here is the Debug results: CB = Combo TA = TextArea B=Before A=After , the numbers are the caret position (also attached as a picture )
CB - append B 0
CB - append A :1
CB - append B 0
CB - append A :2
CB - append B 0
[Code] ....
combo caret code.png
33.5 K
combo caret debug results .png
9.9 K
my form.png
28.4 K
View Replies
View Related
Jan 19, 2014
So I have an array of objects, each with their own position, I tried switch the references in the array of two objects, then repainted (immediately), but the two objects aren't switching positions on screen...does this even work?
View Replies
View Related
May 5, 2015
I want to take my 5x5 array that reads data from a file, add the rows and columns, then print out a new 6x6 array with those values. Here is my code that shows I understand everything except this.
import java.io.*;
import java.util.*;
public class prog470cAddingRandC
{
public static void main (String [] args)
{
//read the file
Scanner inFile=null;
[Code] ....
I was told in a previous question to make the starting array 6x6 but that is not working. How do I take sum1 and sum2 and store that along with the values of the old array and print it?
View Replies
View Related
Feb 6, 2015
I have an assignment in which I have to design a method where I add an object at any given position in an array and shift the elements already in the array to make room. For example I have a collection class which holds trading card objects. So I wish to add a new trading card to this collection at a specified index or position with out deleting the current object already stored in the array . All this has to be done without the use of array lists, vectors or any abstract data types besides arrays . My question is how do I accomplish this . Say I wish to add a new trading card in position 4 the new card is added to my array and the card currently in position 4 gets moved to position 5 and the card in position 5 gets moved to 6 etc. The maximum amount of cards my collection can hold is 100. How would I add my trading card object to the specified position without overwriting what is currently there and shifting all other elements?Here is my current code.
public class CardCollection {
public BaseballCard [] collection;
final int MAX_CARDS = 100;
public CardCollection() {
collection = new BaseballCard[MAX_CARDS];
}
public CardCollection(BaseballCard[]c)
[code]...
position refers to the position in the CardCollection and not the position inside the array.
View Replies
View Related