Custom Input Management Class - No Output

Aug 25, 2014

My input class

package core;
import java.util.ArrayList;
import org.lwjgl.input.Keyboard;
public class Input{
public static final int num_key = 78;
private static ArrayList<Integer> currrentkeys = new ArrayList<Integer>();
private static ArrayList<Integer> downkeys= new ArrayList<Integer>();
private static ArrayList<Integer> upkeys = new ArrayList<Integer>();

[Code] ....

View Replies


ADVERTISEMENT

Input / Output Using Process Class?

Jun 6, 2014

I want to do basic input/output using Process class. I basically wish that, I should ask user his name and when user provides his name then I would print "Hello '[name]'"

import java.io.*;
public class ReadAndPrintName
{
static Process p;

[Code]....

View Replies View Related

Generate QR Code From Input Text And Display Information About Input / Output Bits

Nov 12, 2014

I am trying to write a program that will generate a QR Code from an input text and also display some information about the input/output bits. So far I have created the frame and what to do next. And I'm not sure if I am on the right track since my level of programming is not that great. By the way, I am using zxing libraries from GitHub. I know, there are plenty of generators online for the QR Code, but that is not what I am looking for. As you can see on the attached image, I am more interested in the efficiency of encoding 2D data. Also, I noticed that almost all the online projects regarding 2D codes are for Android. Which is not very useful.

// QR Code Generator
package qrcode;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

[Code]....

View Replies View Related

Web Services :: Custom Class With Byte

Dec 23, 2014

I'm trying to create Web Services with Eclipse (Java Runtime 7 (also tried 8) Tomcat 7 (also tried 8).Web Service with parameter "byte[]" and return value "byte[]" works fine.Web Service with parameter "myOwnClass" and return value "myOwnClass" works also fine.But if I have a "byte[]" element in "myOwnClass" and I run my Client test program I get the following error:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.NumberFormatException: For input string: "MTExMTExMTExMQ=="

Why? I don't have any numeric element (such as int ...) in my class members!?

View Replies View Related

Servlets :: From Json To Custom Class Using Gson?

Sep 18, 2014

I want to send JSON object from html file and receive it in servlet and then convert it into custom class of LastMove using

new Gson().fromJson(input, LastMove.class);

how to do it?

View Replies View Related

Custom Class Loader For Loading JAR Files

Mar 30, 2015

I'm writing a custom class loader to load some .jar file

public class IQJarClassLoader extends ClassLoader { 
private String jarFile = "json-simple-1.1.1.jar";
private Hashtable classes = new Hashtable();
public IQJarClassLoader() {
super(IQJarClassLoader.class.getClassLoader());

[Code] .....

I receive this exception :

Exception in thread "main" java.lang.ClassCastException: org.json.simple.parser.JSONParser cannot be cast to org.json.simple.parser.JSONParser

Everytime, because i don't cast. Casting an object to a class with the same name loaded by different classloaders is no different than trying to cast.

View Replies View Related

Home For Collection Of Objects Of Custom Class

Mar 31, 2015

Where should I keep a collection of instances of my custom class? In the class itself in a static variable?

class Item {
int quantity;
static ArrayList<Item> list = new ArrayList<Item>();
Item(int q) {
quantity = q;
list.add(this);
}
// Some methods and whatnot.
}

Is it fine like this or should I implement the collection elsewhere? What say you?

View Replies View Related

Input And Output Via JTextField

Jun 29, 2014

How would I display certain output text if the text entered equaled "text".

So lets say you enter a question into a JTextField. You press a button that submits the text. The output displayed depends on what the question you asked was.

Think about it as "If question = What color is the sky? On submit, display text "Blue". How to implement this.

View Replies View Related

Formatted Input And Output In Java?

Feb 23, 2014

What are formatted input & output in Java? I want to know the difference between general "input & output" & "formatted input & output"? And what is the reason of the naming it as formatted.

View Replies View Related

String Input / Output And Casting

Oct 2, 2014

I have to create a program that uses the Scanner in String input and Output that will enable the user to convert

double -> int
int -> byte
int -> short
int -> hex-string

The output should look something like this:

Syntax: convert <value> <type>
convert 15.5 int~> 16
convert 128 byte~> -128
<type>: int, byte, short, hex, decimal
Syntax: max <type>
max byte~> 127
<type>: int, byte, short

[Code] ....

View Replies View Related

Use While Loop With Input And If Statement For Output

Apr 26, 2015

Here is my code so far. I am trying to get the WHILE LOOP to work so the user inputs a number, the if statement prints the output and then it returns to ask for another number and goes again and again looping :

import java.util.Scanner;
public class ifwhileloop {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
double nmbr;

[Code] ....

View Replies View Related

GUI And Multiple Run Management

Nov 19, 2014

I am trying to launch a GUI to my agent-based model (Repast and Eclipse) so that being able to run the model for many times. I am going to produce input parameters based on different distributions for different runs from GUI. Usually we should use batch file for different runs. However, I want to use GUI for this reason because I have GUI that can take care for one run but not for many runs.

View Replies View Related

Input Letter - Output Whether Vowel Or Consonant?

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

Java Input / Output Program Using Threads

Feb 24, 2014

I am trying to write a program in Java that uses threads.Below is the program requirements:The goal of this assignment is to create a routine which creates multiple threads, has them do work in parallel, and terminates when the last thread has finished.

The Scenario: There are several groups of people in a bar watching the Olympics cheering for their country. Each group will cheer for their country some given number of times, with a random pause (between 2 and 5 seconds) between each cheer. There is enough room at the bar for up to ten different groups to sit (each would be cheering for a different country).

The Program: The task is to write a program that will simulate these cheers using threads. The program should be called cheer.X (X being the language of choice). You may use any language that supports threading. When the program is run it should ask for the number of countries and then the name and how many times it will be cheered for. The main function will then create a thread for each team and each thread is responsible for cheering the specified number of times for the correct team at the random interval. You will submit the proper source code file for me to open and compile myself, not an executable.

An example run would look something like this: How many countries are supported at the bar? 3 Enter the first: China How many cheers? 2 Enter the second: USA How many cheers? 4 Enter the third: Russia

View Replies View Related

Program Should Output Depending On Input Number

Apr 15, 2014

The program should has the output depending the number I'll input. (The number should be from 1-9) . This is the program's output should be:

Input number: 4

Output:
# # # 1 # # # # #
# # # 2 # # # # #
# # # 3 # # # # #
1 2 3 4 5 6 7 8 9
# # # 5 # # # # #
# # # 6 # # # # #
# # # 7 # # # # #
# # # 8 # # # # #
# # # 9 # # # # #

(Example 2):
Input numbers: 8

Output:
# # # # # # # 1 #
# # # # # # # 2 #
# # # # # # # 3 #
# # # # # # # 4 #
# # # # # # # 5 #
# # # # # # # 6 #
# # # # # # # 7 #
1 2 3 4 5 6 7 8 9
# # # # # # # 9 #

(Example 3):
Input number: 5

Output:
# # # # 1 # # # #
# # # # 2 # # # #
# # # # 3 # # # #
# # # # 4 # # # #
1 2 3 4 5 6 7 8 9
# # # # 6 # # # #
# # # # 7 # # # #
# # # # 8 # # # #
# # # # 9 # # # #

I'm not asking the code to make this program, I have trouble to understand the algorithm to make this program ...

View Replies View Related

How To Use File Input / Output In Addition To Exception Handling

Dec 2, 2014

I am trying to learn how to use file input/output in addition to exception handling... The problem is my textbook wrote this chapter for a version of Java that hasn't come out yet, so everything I do "according to the textbook" doesn't work. any feedback on correcting these exception errors because I am not sure what is causing them or how to fix them.

I was able to have it display the name of the book in the Book.txt file, but when I added the second part if the file doesn't exist, that's when the errors came up and it wouldn't compile.

import java.io.*;
import java.util.*;
public class DisplayBook
{
public static void main(String[] args) {
try {
File book = new File("Book.txt");
FileInputStream in = new FileInputStream(book);

[Code]...

These are the compilation error messages I am receiving: (I have managed to get it down from 7 errors to just 4, but now I'm stuck)

DisplayBook.java:15: error: unreported exception IOException; must be caught or declared to be thrown
while ((letter = in.read()) != -1) //if file exists, displays book title
^
DisplayBook.java:24: error: unreported exception FileNotFoundException; must be caught or declared to be thrown

[Code] ....

4 errors

View Replies View Related

Take Input From User And Append Some Text To It - Output Null

Sep 20, 2014

I'm using one method to take input from the user and append some text to it, then I am trying to return the value of the variable and use another method to print it out. But for some reason whenever I try doing this I can't print out anything and I only get a "null" output. Why this is happening?

package Homework3;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Homework3 {

[Code] .....

View Replies View Related

Input Ten Words And Output Them Backwards In MSDOS Environment

Sep 4, 2014

how would a program code look like, input ten words and output them backwards in a msdos environment. My code this far is:

package baktext;
import java.util.*;
import java.io.*;
import java.awt.*;
//public static String baklänges(String s) {
//}
public class Baktext {

[Code] ....

View Replies View Related

Area Calculator - How To Move All Input / Output To Main

Nov 11, 2014

I am stuck on one of the projects: Area Calculator

I am able to code an area calc that works, but am unsure how to move all the input/output to main like the project wants. here is a piece of my code so far:

public static void main( String[] args )
{
Scanner kb = new Scanner(System.in);
int base = 0, height = 0, width = 0, radius = 0, choice;
System.out.println( "-=-=-=-=-=-=-=-=-=-=-" );
System.out.println( "1. Triangle" );
System.out.println( "2. Rectangle" );
System.out.println( "3. Square" );
System.out.println( "4. Circle" );
System.out.print( "Pick a shape: " );

[Code] ....

I have the same thing for rectangle, square, and circle (of course with the correct formulas) and the program works perfect, but the assignment is still wrong until I can move the input/output to main. what do I do?

View Replies View Related

Time Management System

Oct 27, 2014

I'm in the middle of building A time management system for myself.I'm currently using JodaTime for timing in java. I just can't figure out who to save my data like, the starttime, stoptime and day time.

public void save() throws SQLException {
String checkSql = "select count(*) as count from Time where id=?";
PreparedStatement checkStmt = con.prepareStatement(checkSql);
String insertSql = "insert into Time (id, day, starttime, stoptime, overtime, exception, hours) values (?, ?, ?, ?, ?, ?, ?)";
PreparedStatement insertStatement = con.prepareStatement(insertSql);

String updateSql = "update Time set day=?, starttime=?, stoptime=?, overtime=?, exception=?, hours=? where id=?";
PreparedStatement updateStatement = con.prepareStatement(updateSql);

[code]....

View Replies View Related

Thread And Clock Management

Dec 19, 2014

I have objects (baddies in a game) that have individual clocks/counters assigned to them (when I make an object, I fill an integer based array list with a new digit entry at a value of one) that all happens in threads. then in another thread, I am checking the whole list of clocks, to see if any are equal to a wanted value , then I am taking an action and reseting the clock at that point on the array list.

now, the problem is:even though my code says " yes, I've taken that action because the value of array position x was >= specified value and I will now reset the clock" it doesn't reset the clock. Here is what it looks like

*these are excerpts taken from a really big program, however they should stand on their own as they are individual classes

Java Code:

public class levelclock extends Thread {
public void run() {
while (Run2 == true) {
if (Run == false) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();

[code]....

(Attached, just open up the zip and read the .txt)

View Replies View Related

Display User Input In Lower Case - Why No Output In Second TextField

Jun 2, 2014

I've done a lot of hardwork for this assignment but I don't know what's why the second textfield which is for output is blank.

All I want is to get the input from user in textfield a and display it in textfield b in lower case.

public void KeyPressed (KeyEvent ke) {
String letter2="";
if(ke.getKeyCode()==KeyEvent.VK_A)
{
letter2=letter2+"a";
btextfield.setText(letter2);

[Code] .....

View Replies View Related

JOption Pane - Output Number With Greatest Value From User Input

Nov 7, 2014

Using JOptionPane,ask for 10 numbers from the user.Use an array to store the values of these 10 numbers.Output on the screen the number with the greatest value.

View Replies View Related

User Input 3 Sides - Output Invalid If Does Not Make A Triangle

Nov 4, 2014

I had to make a program that allows the user to enter 3 sides and it should output "invalid" if it does not make a triangle and if it does make a triangle it calculates the area of the triangle and it doesnt seem to do anything but say "invalid" as the out put.

import java.util.Scanner;
public class MyTriangle {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean valid = true;
double side1, side2, side3, area, A;
 
[Code] ....

View Replies View Related

User Input 2 Ints - Output True If One Is In Range Otherwise False

May 14, 2014

How do I make it so that if both numbers are entered between 10 and 20 it will print false?

The assignment: Ask the user to enter 2 ints. Output "true" if one of them is in the range 10 - 20 inclusive, but not both. Otherwise output "false"

12 99 → true
21 20 → true
8 99 → false
15 17 → false

import java.util.Scanner;
 public class Practice {
 public static void main(String[] args) {
 //get user input
Scanner user_input = new Scanner(System.in);
System.out.print("Enter a number: " );

[Code] ....

View Replies View Related

Prompt User To Input Integer And Then Output Both Digits Of Number And Their Sum

Jun 7, 2015

Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. 
 
Now I have a code for spacing out the integers, and I have a separate code for adding the digits. But I am not sure how to merge them together. Both of them work independently
 
Spacing code:
import java.util.*;
public class SumoftheIntegers
{
static Scanner console=new Scanner(System.in);
public static void main(String []args) {
int num1, test, rem;
int counter = 0;

[Code]...

Now the sum of the integers code:
 
import java.util.Scanner;
public class sum
{
    public static void main(String[] args)
    {
        // Create a Scanner
        Scanner input = new Scanner(System.in);
// Enter amount
        System.out.print("Enter an integer: ");
        int integer = input.nextInt();

[Code]...

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved