Cannot Enter Info From Keyboard In A Method

Jun 21, 2014

I want to enter the triangle data in the method and every time I try to compile the program I get the error message--cannot find symbol.

import java.io.*;
import java.util.*;
public class trianglemethod {
public static void main(String [] args) {
Scanner kbreader = new Scanner (System.in);

[Code] .....

View Replies


ADVERTISEMENT

Java Need To Enter 5 Grades And Can Only Enter 1 For Grade Conversion

Sep 13, 2014

How to improve my code. I finally was able to create a program that gives you the corresponding letter grade, when you enter in a numeric grade without using an array. The only issue left is that I have to be able to enter 5 grades at a time, and it give me the letter grade for all 5. I have the programming working, but only am able to enter 1 at a time. I am not sure what kind of loop or if I am supposed to use a loop.

public static void main(String[] args){
{
int grade = 0;
Scanner input = new Scanner(System.in);
System.out.println("Enter : ");
grade = input.nextInt();
if (grade >= 90)

[Code] .....

View Replies View Related

Getting All Info From One Class To Another

Feb 11, 2014

I want to get info from one class to another LIKE ALL information.

View Replies View Related

JFrame - Gathering Info From Net?

Nov 7, 2014

I'd like to know how to,

1. Connect to Google,
2. Search for something,
3. Return a SCREEN SHOT of the results.

I'm assuming this involves loading the webpage into a JFrame, or is there an easy workaround?

View Replies View Related

JSF :: Some RowSet Info Not Being Displayed?

Apr 22, 2015

I am reading from a database(SQL Server 2012) and storing that information in a ResultSet. I am then trying to display that information using a DataTable.

Here is my managed bean

/*
* 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 clientspage;
import java.io.Serializable;

[Code].....

The ID and the commandLinks are being displayed but the Client is not.

View Replies View Related

How To Get Info From Sites For Using In Program

May 10, 2014

I was wondering where can I find info on how to grab info from websites to use in a program?

View Replies View Related

Client Info On Server Side

Apr 6, 2014

I want to ask that, when a server listen to A port and it accepts a request from a client then the server accepts the request using accept method,but how does the server get the info about the client like wat is the port no and ip address of the client,I read a answer regarding this that Server never gets the port no of client only the ip address and it connects to client using a connection stream but as far I know from networking, a device must have the ip address and port no of the device it wants to connect to.

View Replies View Related

Methods To Get User Info Like Age / Email Address?

Oct 28, 2014

how should i write appropriate methods to get user info like age, email address etc?

View Replies View Related

How To Pass Info To Constructor From A Text File

Feb 9, 2015

Suppose there're two classes: Exam and MainExam (contains a main method). class Exam has a constructor public Exam(String firstName, String lastName, int ID). Class MainExam reads data from a textfile. For example, the data can be: John Douglas 57. How can one pass data to the constructor from a textfile?

View Replies View Related

How To Find Needed Info From Java API Documentation

May 13, 2015

Let's say I'd like to print out something as a prompt without end with a new line char, so the standard System.out.println() is not an option and I'd like to find something else inplace of println().

Where to find that? I googled about that and learned printf() is the one I want, but how to get it from java api documentation.

View Replies View Related

UDP Voice Chat - Play With The Index Of Mixer Info Array

Jan 18, 2012

I was trying to make a UDP voice chat but i couldn't make the receive method work! so i just move on to work with TCP. I found a simple code that i found it pretty easy to understand,but i couldn't make it work, always stuck within exception.

Here is the output I got:

Available mixers:

Java Sound Audio Engine

Microsoft Sound Mapper

WinOS,waveOut,multi threaded

java.lang.IllegalArgumentException: Line unsupported: interface TargetDataLine supporting format PCM_SIGNED, 8000.0 Hz, 16 bit, mono, little-endian, audio data

And here is the code

sender:

Java Code:

package sender;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.sound.sampled.AudioFormat;

[Code] ....

I tried to play with the index of mixerInfo array in the line

Java Code:

Mixer mixer = AudioSystem.getMixer(mixerInfo[1]); mh_sh_highlight_all('java');

But nothing happened. How I can fix that?

View Replies View Related

Invoke Some Methods In For Loop In Order To Print Some Info Stored In A List

Apr 28, 2014

I am trying to invoke some methods in a for loop in order to print some info stored in a List. But for some reason, compiler pops a message saying "cannot find symbol - method getEmpID(). You are using a symbol here (a name for a variable, method or class) that has not been declared in any visible scope." But I am pretty sure that method getEmpID (as also getName(), getAfm(), and payment() ) have been declared as public.

Note: My List contains objects of different type (SalariedEmployee, HourlyEmployee). I hope this is not the factor causing this problem.

Java Code:

import java.util.*;
abstract class Employee{
private String name = "";
private String afm = "";
private long EmpID;
static long count=0;

[code]....

View Replies View Related

Program Prompt For Input File / Take Its Info And Write To Report - Nullpointer Exception

Apr 17, 2014

I've got a nasty nullpointer that I have tried to resolve to no avail as of yet. The program should prompt for a listings.txt file and take its info and write to a report file. Here's the stacktrace:

run:

Input file: listings
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.<init>(Writer.java:88)
at java.io.PrintWriter.<init>(PrintWriter.java:113)
at java.io.PrintWriter.<init>(PrintWriter.java:100)
at kettask2b.PropertyListingsReport.main(PropertyListingsReport.java:34)
Java Result: 1

Some adjustments that I have attempted are:

BufferedWriter pwfo = null;
for (int i = 0; i < args.length; i++) {
String string = args[i];
pwfo = null;

[Code] ....

Here's the code:

package kettask2b;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

[Code] ....

View Replies View Related

Going Through All The Keys On Keyboard One At A Time

Jul 14, 2014

I am writing a code that tries to figure out the users password by going through every possible key (brute force). Although I think its going to work, it looks EXTREMELY inefficient to me, since its just a huge switch statement for each character -- 94 total, including the shift values. Is there a built in method in the JAVA API that goes through every key or something?

Here is my code for that segment:

public char[] HackingPassword(){
char[] passChars = this.password.toCharArray();//convert the password to char[]
char[] hacking = new char[passChars.length];//make the hacking variable same size as users password
int nextCharValue = 0;//this is used to cycle through the keyboard
//check each letter of hacking to match with password
for(int i = 0; i < passChars.length; i++){

[Code] .....

View Replies View Related

How To Get User Keyboard Input

Sep 4, 2014

I created a scanner object but it's not asking for any input. when I create a new scanner and then tell it to print it it just prints a bunch of weirdness when AFIK it should be asking me to type something and then it should repeat what i entered.

View Replies View Related

Reading Values From The Keyboard?

Aug 21, 2014

why we are not able to read second string in this program.

String s1,s2,s3;
String decider;
Scanner sc = new Scanner(System.in);

[Code].....

Note: If I uncomment line num 9 it works fine

View Replies View Related

Reading The Name Of The File From The Keyboard

Feb 20, 2014

Write a program that extracts words from a file. For the purposes of this program, a word is defined as a series of adjacent letters. Only print words that are at least four and no more than 12 letters long. Print each word on a different line.

The program should read the name of the file from the keyboard.

************************************************** ************************************************** **************

I need to get the filename from the user for this particular program. Usually I would have the name of the file prewritten into the source code like this....

Scanner input = new Scanner(new File("gettsy_burg.txt");

I tried different ways but I just can't seem to figure it out.... I guess what I'm really asking is how to rearrange Scanner input = new Scanner(new File("gettsy_burg.txt"); since I want the user to input the filename instead of the filename being prewritten by the programmer(me).

This is what I have so far to let the user for input....

Scanner keys = new Scanner(System.in);
System.out.println("Enter the filename: ");
String fileName = keys.nextLine();
keys = new Scanner(new File(fileName));

View Replies View Related

Reading Name Of File From Keyboard

Feb 20, 2014

Write a program that extracts words from a file. For the purposes of this program, a word is defined as a series of adjacent letters. Only print words that are at least four and no more than 12 letters long. Print each word on a different line.

The program should read the name of the file from the keyboard.

************************************************** ************************************************** **************

I need to get the filename from the user for this particular program. Usually I would have the name of the file prewritten into the source code like this....

Scanner input = new Scanner(new File("gettsy_burg.txt");

I tried different ways but I just can't seem to figure it out....

View Replies View Related

Type In A Name And It Will Search Through Each Object And Print Back Corresponding Object Info

Nov 19, 2014

I am trying to get this to where I can type in a name and it will search through each object and print back the corresponding object info.

Java Code:

import java.util.Scanner;
public class MyPeople {
public static void main(String[] args) {
Person[] p = new Person[] {
new Person("Chris", 26, "Male", "NJ", "Single"),
new Person("JoAnna", 23, "Female", "NJ", "Single"),
new Person("Dana", 24, "Female", "NJ", "Single"),
new Person("Dan", 25, "Male", "NJ", "Single"),
new Person("Mike", 31, "Male", "NJ", "Married") };

[code]....

View Replies View Related

How To Make Print Employee Button To Print Info Of Other Class

Apr 12, 2014

Basically the class is supposed to have a static variable that keeps track of the number of companies (numberOfCompanies) that have been created and a static method that returns the value of this variable. I need to have a constructor and a method to addEmployee, a method to printCompany, and a toString method. The addEmployee method will check that there is only 1 salesperson, 2 designers, and 4 manufacturing persons at a time and will check that there are no more than 7 employees of the company.

The addEmployee method will return a String indicating what the error is (i.e. "There is already a sales person in this company") or a null if the employee was added. If attempting to name a third company, an error message will be shown. what i have so far but my print company mmethod returns null company class :in which i am obliged to use inputdialog because it says that it cannot return void when i use the showmeassage diaolog.

company class:

import java.util.ArrayList;
import javax.swing.JOptionPane;
public class Company {
private ArrayList<Employees> list ;
private static int numberOfCompanies;

[Code] ....

error message when print button is clicked:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
at javax.swing.JOptionPane.createInternalFrame(Unknown Source)
at javax.swing.JOptionPane.showInternalOptionDialog(Unknown Source)
at javax.swing.JOptionPane.showInternalMessageDialog(Unknown Source)

[Code] ......

View Replies View Related

How To Avoid Keyboard Auto-repeat

Oct 8, 2014

I wanted to make a small program to move a small rectangle by pressing the WASD keys. The program works, except that when I hold a key to move the rectangle, after a second, auto-repeat starts up, and the rectangle motion accelerates. I want to prevent automatic repeat to activate, so that the rectangle moves at a constant speed when I hold a key and stops when I released. Here is the ButtonMotion classe :

import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.KeyStroke;

[code]....

View Replies View Related

How To Get Double Variable From Keyboard Input

Apr 8, 2014

I am testing to get a double value from keyboard input as below?

import java.util.Scanner;
public class EchoLine{
public static void main(String[] args){
double amount;
Scanner myScanner=new Scanner(System.in);
amount=myScanner.nextDouble();
System.out.println(amount);
}
}

I type 5.95 in Console View of Eclipse but as a result I get an error on line 9.

View Replies View Related

Create Backspace Button In Keyboard (GUI)

Mar 26, 2015

I want to use backspace button in my keyboard how can i create this button in my code ???

View Replies View Related

LWJGL Keyboard Inputs Not Recognized

May 10, 2014

I wanted to create a simple window with the LWJGL and a key input request which closes the window.I also wanted to create the classes in seperated packages, so it's more organized.The window displays but if I press that certain key nothing happens.Here is the Main class:

package bb.main;
import bb.input.Input;
import bb.main.render.SimpleRenderer;
public class Main {
public static void main(String[] args){
SimpleRenderer createWindow = new SimpleRenderer();
Inputinput= new Input();

[code]....

View Replies View Related

How To Get Keyboard Input Without Focus On The Frame

Jan 29, 2015

so i'm working in a chat program and i'm trying to make it so that you are able to open another tab yet still be able to chat.

right now the client that the user download uses the keyadapter to get the keyboard input, but whenever the user un-focus the chat window, the keyadapter no longer gets the keyboard input.so is there another way i can get the keyboard input? so it doesn't matter what window you are focused on, you get the keyboard input either way?

View Replies View Related

Keyboard Class Is Not Configured Properly

Jul 4, 2014

package com.vesron.primes;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;

[code]....

The parameter for the starting y is "fy" (Half of the screen). When I use the keys "z" and "x" it translates one pixel at a time left and right. That is good, but when I use the keys "a" and "s" it will double each time (good), but the starting y will drop significantly (bad). I tried manipulating the "x" and "fy" variables, but to no avail.

View Replies View Related







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