Making Letter Bounce Off Of The Edges Of Frame
Jan 9, 2015
I am trying to make a letter bounce off of the edges of the frame, but im stuck .
Java Code:
import javax.swing.*;
import java.awt.*;
public class MainProgram extends JFrame{
public static void main(String[] args) {
// TODO Auto-generated method stub
MainProgram frm = new MainProgram();
frm.setTitle("Moving a letter");
[Code] ....
View Replies
ADVERTISEMENT
Aug 12, 2014
I've got to make a ball bounce around a screen.... From what I can gather they seem to hold back useful java code.
anyway, i've changed the code over and over, and think this is the most succinct way i can manage it. but i have a problem. where i've marked the code (*****) and the following line are conditional on each other. so one won't provide the correct answer without the other line executing first, and vice versa (ignore the code after, i haven't looked at where that should be yet ). Anyway I don't really want to rip the code apart, again, because i'm pretty sure it's close.
View Replies
View Related
Oct 22, 2014
I have a problem with functions connected to strings.
I have a random String, e.g. "Hello World!" and I have to change every capital Letter into a small letter and vise versa. This alone would be fairly simple, but I have to do it with two other strings.
lowercase= "abcde...z" and
uppercase="ABCDE...Z". Every small letter stands at the very same position as the capital letter, but in the other string.
There should be a letter for letter search in lowercase and uppercase for the letters of "Hello World".
How I could solve the task, however I need a way to search the first string, here "Hello World", according to position. A statement which does: "Give me the letter of position x". This found letter should be able to be stored in a variable or else be able to be used by another statement. And it should be compatible with a for lope.
View Replies
View Related
Apr 15, 2014
Example : I have code and name but my code must start with the first letter of the inputed name if the 2 input is match it will be inserted into database
code = "A"001
name ="Angela"
= success this will inserted into database
else
code ="B"002
name="Angela"
=failed this will not inserted into database
else
code="A"003
name="Andy"
=success still accepts the input cause they have diff code number
What I am thinking on this was compare the code the name? if == it will be inserted but how do i get the 1st letter of the input name?
View Replies
View Related
Oct 17, 2014
I'm trying to read from a file. we made an array of LinkedList and when I'm reading from the file i get a runtime error "index out of bounce in line 66"
import java.lang.*;
import java.util.*;
public class HashTester{
LinkedList_t [] hash;
LinkedList_t [][] doubleHasher;
int size;
[Code] .......
View Replies
View Related
Jan 30, 2015
How to create histogram in JavaFX ? Is it possible to do it using BarChart? how to label the bin edges (ticks)?
View Replies
View Related
Apr 14, 2014
I'm trying to print (to the printer) a small image 265x35 px and it is printed in very poor quality with jagged edges. When I'm printing it from any other program (e.g. Word, mspaint, etc) it is printed clearly.
Also, the image is printed bigger than it's normal size (approximately 25%). But, I'm not doing any scale in my code. I did scaled it down to the right size, but the quality still remained very poor and jadged.
The image is a transparent PNG file. I tried with a BMP too, but I got the same results.
I'm using
Graphics g;
g.drawImage(headerLogo, x, y, headerLogo.getWidth(), headerLogo.getHeight(), imageObserver);
View Replies
View Related
Jan 28, 2015
How can I do this: program to compare two files that which has data like node id: which it is connected to. like 3: 5 7 12 5: 7 14 9 etc. so this type of content is there in both the files. I need to compare these two files and count new edges for each node and also total new edges.
How can I do this? I tried and learnt taking files as input and read the normal text content.
This is what I tried :
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package comparetwofiles;
import java.io.*;
import java.util.*;
[Code]...
View Replies
View Related
Oct 8, 2014
Write a program that continuously asks for an alphabet letter, and stops when a non-alphabet letter is entered. Then output the number of upper case letters, lower case letters, and vowels entered ....
View Replies
View Related
May 20, 2014
import javax.swing.*;
public class ThreeLetterAcronym{
public static void main(String[] args){
String phrase = "";
String firstWord = "";
[Code] ....
View Replies
View Related
Nov 11, 2014
So if I wanted to tell the user that the fifth letter they entered is "____" how would I do that.
I am prompting the user to enter a word and then displaying the length of the String. Now I want to display to the user what the fifth letter of the String they entered is.
import java.util.Scanner;
public class StringPractice
{
public static void main(String [] args) {
Scanner input = new Scanner(System.in);
String word;
int lenght;
[Code] ....
View Replies
View Related
Mar 9, 2014
I'm writing a java program in eclipse of a tic-tac-toe game. I have to create it using JTextField's only I'm having trouble where the JTextField will only accept one letter and will only accept X and O is there any particular way to do this I started off with this piece of code
String text=tf1.getText();
if(text.length()>1) {
System.out.println("this is not allowed");
tf1.setText("");
But it doesn't work so is there something I'm missing....
View Replies
View Related
Mar 8, 2014
I'm trying to figure out the correct way to replace number into letter. In this case, I need two steps.
First, convert letter to number. Second, restore number to word.
Words list: a = 1, b = 2, f = 6 and k = 11.
I have word: "baafk"
So, for first step, it must be: "211611"
Number "211611" must be converted to "baafk".
But, I failed at second step.
Code I've tried:
public class str_number {
public static void main(String[] args){
String word = "baafk";
String number = word.replace("a", "1").replace("b","2").replace("f","6").replace("k","11");
System.out.println(word);
[Code] .....
Result for converting to number: baafk = 211611 But, result for converting above number to letter: 211611 = bkfk
What do I miss here?
How to distinguish if 11 is for "aa" and for "k"? D
View Replies
View Related
Dec 24, 2014
I had a list of some numbers having a prefix A like A12 , A55, A76 ,A111 ,A888, A88 ,A880 A111 , A11,A1
I need to sort this list so the result would be A1,A11,A12,A55,A76....
How to do this. Can I use arrays.sort method to achieve the same or any other way.
View Replies
View Related
Nov 11, 2014
The point of this program is to search for a specific character in a text file. I want the program to find a character in the file "letterCounter.txt".
package lettercounter;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.FileInputStream;
[code]....
View Replies
View Related
Jan 31, 2014
/*This program will convert integer grades to letter grades and say how many A's, B's, C's, D's , F's do we have
public class DSlab3 {
private char LetterGrades;
private int IntegerGrades;
//default constructor
public DSlab3() {
LetterGrades =' ';
IntegerGrades = 0;
[Code] .....
View Replies
View Related
Apr 14, 2014
The purpose of this project is to determine the letter grade of students. The program needs to accept two command line arguments:
The first being the name of a disk file that contains the names of students, and their test scores, separated by commas followed by one or more spaces. Each line in the file will contain scores for one student.
The second argument is the name of an output disk file. The program is supposed to create a new output disk file using that name.
The number of students in the input file is unknown during compile time. The name of input and output files could be anything and only known during run time. Additionally, the average scores, along with the minimum and maximum scores for each test are to be displayed in the console.
Calculation: Final Score = quiz1 * .10 + quiz2 * .10 + quiz3 * .10 + quiz4 * .10 + midi * .20 + midii * .15 + final * .25
Final Score >= 90% then letter grade is A, 80%-89% B, 70%-79% C, 60-69% D, <= 59% F
input_data.txt:
firstName lastName, 100, 90, 80, 100, 89, 99, 88
firstName lastName, 90, 90, 100, 100, 99, 100, 95
firstName lastName, 100, 90, 100, 70, 78, 78, 80
firstName lastName, 80, 90, 90, 100, 89, 99, 85
etc.
output_data.txt
firstName lastName: B
firstName lastName: A
firstName lastName: F
firstName lastName: B
firstName lastName: C
averages (to appear in console)
Q1 Q2 Q3 Q4 MidI MidII Final
Average: 82.25 80.38 82.85 83.88 81.38 84.13 78.63
Minimum: 60 54 38 62 62 60 50
Maximum: 100 90 100 100 99 100 95
Press ENTER to continue...
Here's what I have so far :
import static java.lang.System.out;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
public class LetterGrader {
[Code] .....
View Replies
View Related
Nov 25, 2014
I need to know how many four letter strings I can generate that begin with the letter "v". Now I had been testing many ways to do this but anm stuck. I can generate a single line up only a certain amount. I need it to continue till it reaches the max number. So since it needs to always start with V i eliminated the need for four and only a 3 letter string.
package javaapplication4;
import java.util.Random;
public class JavaApplication4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Random r = new Random();
int c = r.nextInt(26)+ (byte)'a';
[code]...
View Replies
View Related
Mar 26, 2014
If I have a string of words and want to get a letter from each word (let's say the first), how do I code for anything past two?
For example, if I have North Atlantic Treaty Organization and I want to convert it to NATO I would do something like:
charAt(0) for N
charAt(x + 1) for A
But what do I do for anything past the second string? If I do charAt(x ++ 1) I get an error.
View Replies
View Related
Mar 8, 2014
I'm trying to figure out the correct way to replace number into letter. In this case, I need two steps.
First, convert letter to number. Second, restore number to word.
Words list: a = 1, b = 2, f = 6 and k = 11.
I have word: "baafk"
So, for first step, it must be: "211611"
Number "211611" must be converted to "baafk".
But, I failed at second step.
Code I've tried:
public class str_number {
public static void main(String[] args){
String word = "baafk";
String number = word.replace("a", "1").replace("b","2").replace("f","6").replace("k","11");
System.out.println(word);
[Code] ...
Result for converting to number: baafk = 211611
But, result for converting above number to letter: 211611 = bkfk
How to distinguish if 11 is for "aa" and for "k"? Do you have any solutions or other ways for this case?
View Replies
View Related
Mar 16, 2015
I am trying to create a program for my class that requires the input of a letter and the output of whether or not it is a vowel or a consonant. I am using eclipse, it is giving me no errors, but when entering the letter i get an error in the console
import java.util.Scanner;
public class w0571505_a2a {
private static Scanner a;
public static void main(String[] args) {
// enter letter
System.out.println("Enter a Lowercase Letter");
[Code] .....
This is what i have...
View Replies
View Related
Sep 20, 2014
I'm trying to convert the first letter of every word in a String to uppercase. I've managed to isolate the first letter of every word and then make it uppercase but I don't know how to replace it.
public static StringBuffer makeUpperCase(){
String str = String.valueOf(input2);
for(int i = 0; i < str.length(); i++){
if(str.charAt(i) == ' '){
char var = str.charAt(i + 1);
var = Character.toUpperCase(var);
System.out.println(var);
}
}
View Replies
View Related
Nov 28, 2014
So far I've got it where the program is reading the file and returning
a:0
b:0
c:0
d:0
e:0
f:0
g:0
h:0
i:0
j:0
k:0
l:0
m:0
n:0
o:0
p:0
q:0
r:0
s:0
t:0
u:0
v:0
w:0
x:0
y:0
z:0
But I need it to print the letters and then the total amount of each character that is found in the file.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
[code]....
View Replies
View Related
Sep 29, 2014
I can't get my code to print it like it's on the picture.
import javax.swing.JOptionPane;
import java.util.*;
public class BokstavTeller
{
public static void main( String[] args ) {
String input = JOptionPane.showInputDialog(
[Code] .....
View Replies
View Related
May 1, 2014
I am trying to write a simple program that checks if a user's input has a specific letter using the ".contains" method but its not doing what i wanted to do. here is my code below.
import java.util.Scanner;
public class secret
{
public static void main(String args[]) {
Scanner sc;
char hidden='a';
String guess;
[Code] ....
View Replies
View Related
Oct 28, 2014
SO for my project, we have to create a program where we input two four letter words, and using a list of words our teacher provided us and only changing one letter at a time, make the words match.For example, you input BALD and CALL and it would output BALD BALL CALLWe have to use recursion to do this, and I'm totally lost as to where to even begin.
View Replies
View Related