User Input - Outputting To Excel Document

Mar 30, 2014

I am currently working towards taking input from the user and storing it in an excel document. However how can I test to make sure that I am trying to save it to an empty cell. Is there some type of method that will check to make sure the cell is empty, otherwise how can this be done?

View Replies


ADVERTISEMENT

How To Convert Excel To Word Document

Oct 7, 2011

How to write a programe for Converting Excel document to word document?

View Replies View Related

Why Won't Read Input File (WordPad Document)

Sep 12, 2014

I keep receiving an error in which State.Fall.txt can not be read. I can't point it directly to a drive because someone else needs to open it. I saved it in wordpad as a text file. My question is what did I do wrong in my code that it can't directly access the wordpad document? 
 
import java.io.*;
public class Main {
/**
* @param args the command line arguments
*
*/
public static void main(String[] args) throws IOException
{
// Create an array of individual state objects to hold 50 items

[Code] ....

View Replies View Related

How To Print PDF In Java - Send Document To Printer Upon User Request

Apr 24, 2008

I've been googling information on how to print a pdf in java, and it seems that the java print api is used more for printing from a swing app. What I'm needing to do is send a pdf document to the printer upon user request. I would like my app to work as follows - User selects pdf to be printed- Program determines pages to be printed and deducts amount from user account- If sufficient money, program sends job to printer automatically without popping up the print screen.- If printed successfully, then program tells user it was printed. I'm able to figure out the rest of the pieces, in regards to user input and determining pages of the pdf, except I don't see how I will be able to print the pdf.

I've tried to use this code

PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob printerJob = defaultPrintService.createPrintJob();
File pdfFile = new File("c://myPdf.pdf");
SimpleDoc simpleDoc = null;
try {
simpleDoc = new SimpleDoc(pdfFile.toURL(), DocFlavor.URL.AUTOSENSE, null);

[Code] ....

But all that I get is junk characters spread across 15 or so pages, for a pdf file that simply says "Hello World". I can open the pdf file on my computer, and print it ok, but when using the above code, it just prints out junk. How I might need to format or setup the pdf so that I can print it correctly. My program could be run on any number of Linux systems, with a multitude of printer types.

View Replies View Related

Java Program That Will Ask A User To Input Grades Until User Inputs Sentinel Value

Apr 9, 2014

Write a java program that will ask a user to input grades until the user inputs the sentinel value -1. The program should test each input to determine whether 0<=grade<=100. If the grade entered is within this range, the program should print "Grade accepted;" if not, the program should print "Invalid input".

View Replies View Related

Program That Takes User Odd Number And Print Prime Numbers Lower Than User Input

Nov 4, 2014

I have been struggling with this program for weeks. This program is supposed to take a user's inputted odd number and then print out all prime numbers lower than that number.

public class PrimeNumber
{
Scanner scan = new Scanner(System.in);
int userNum;
String neg;

public void getUserNum()

[code]...

View Replies View Related

Where To Input Segment To Get User Input Dialog

Apr 9, 2015

Where do I input this segment?

Scanner user_input = new Scanner( System.in );// This line goes at the top with the other global variables

public void getUserInput(){
System.out.print("Enter litres: ");
litres = user_input.nextDouble( );
System.out.print("Enter mileage: ");
mileage = user_input.nextDouble( );
System.out.print("Enter speed: ");
speed = user_input.nextDouble( );

[Code] ....

This is my client file.

class Client{
public static void main(String []args){
Bike R1=new Bike(5.0, 60.0,30.0);//create bike object with params
Bike R2=new Bike();//without params
System.out.println(R1.increaseSpeed());//calling methods
System.out.println(R1.maxDistance());
System.out.println(R2.increaseSpeed());
System.out.println(R2.maxDistance());
}
}

View Replies View Related

Variable Outputting 0 Instead Of Value

Oct 24, 2014

I have code that displays 3 game scores the series total and average. For some reason game 3 outputs 0 and game 1 and 2 output correctly. I don't see anything different that game 3 is doing that game 1 and game 2 aren't so I'm not sure what the problem is.

java file

package com.valenciaprogrammers.mybowlingscores;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
public class BowlingScores implements Comparable<BowlingScores>{
private long id;

[Code] .....

View Replies View Related

If Else / Switch Not Outputting Correctly

Jan 27, 2014

Trying to learn switch statements. Can't figure out what I am doing wrong.

java Code:

import java.util.Scanner;
public class Ok1 {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);

[code]...
When I run, it makes me enter letter = null and it wont output correctly.

View Replies View Related

Why Is Loop Outputting Line Twice

Oct 29, 2014

I have a loop and I was wondering why it is outputting my line twice. Here is the code:

while (x != -1) // closes the program if the user enters -1 for x
{
System.out.println("Which jar would you like to access? Please select a number between 1 and 3. Press -1 to exit.");
x = scan.nextInt();
ourpantry.Selection(x); // tells our pantry class what number the user selected
while ((response != "continue")) // loop continues until user gives a valid response

[Code] ....

This results in the Output:

Would you like to spread jam? Y or N.
Would you like to spread jam? Y or N.

View Replies View Related

Outputting Calendar On Console

Oct 14, 2014

I created a calendar program so when the user enters a day number and a year it would show the calendar for the year . My issue was that I could not get the numbers to line up neatly and how they should look . Also if its not to much trouble I would like to know how to turn this in to a loop .

import java.util.Scanner;
public class Calendar {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a Year");
int Year = scanner.nextInt();

[Code] .....

View Replies View Related

How To Get User Input

Nov 13, 2014

I have been coding in my class at school (Grade 11 Computer science) and i just downloaded the program on my computer at home, unfortunately i cannot access my computer notes at home and i also dont remember certian specifics of coding, so my question is how would i get user input to create a program. The comments are the parts i dont remember. (I am trying to slowly build my memory with this stuff)

Here is my code so far:

import java.util;
[highlight=java]
public class hello_world {
public static void main(String[] args) {
string name;
//WHAT DO I PUT HERE????

[code]....

View Replies View Related

Asking User For Input Twice?

Apr 19, 2014

I'm working on creating a dice game and getting the users input is giving me a really hard time. I have the main game working but this part I'm stuck on. The problem is that it's not giving me the chance to enter the second input when I ask for the game.

//Create Scanner object
Scanner keys = new Scanner(System.in);
//Get chips

[Code]....

*****This is what I get when I run it

run:

How much money would you like to change? 50

You now have $50 in chips.

What game do you want to play? You did not pick dice.

View Replies View Related

Outputting 2 Classes - ToString Method

Apr 22, 2014

My current assignment involves me outputting these 2 classes. Yet I'm not really sure in what manner I should go about doing this. I have tried creating a separate class and outputting my toString methods there but for some reason I am getting an error. .

The error message is thus;

Exception in thread "main" java.lang.NullPointerException
at Vehicle.toString(Vehicle.java:91)
at Run.main(Run.java:17)
 Process completed.

import java.util.Calendar;
public class HireContract {
String reference;
Calendar startDate = null;
Calendar endDate = null;
Vehicle vehicle = null;;
String customerRef;
double rate;

[Code] .....

View Replies View Related

Can Control User Input

Oct 11, 2014

Is there a way you can control user input?

For example, is it possible to only allow the user to enter digits?

View Replies View Related

Formatting User Input

Feb 4, 2014

I have been given a piece of work to do for College that requires me to format user input. For example: This is an example of text that will have straight left and right margins after formatting

will transform into:

This..is..an.example
of..text..that..will
have..straight..left
and...right..margins
after.....formatting

The user inputs the width, in the case above being 20. Each line has to therefore be 20 characters long. All spaces are to be replaced with full stops.

This.is.an.example.o
f.text.that.will.hav
e.straight.left.and.
right.margins.after.
formatting..........
public class Main {
public static void main ( String args[])

[code]....

View Replies View Related

ArrayList - Get User Input And Sum Together

Jul 2, 2014

Goal is to get user input and sum together. I've tried it different ways. This is the one with the least amount of problems.

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.lang.Integer.parseInt

ArrayList<Integer> leftCU = new ArrayList<>(); {
System.out.println
("Please enter one at a time the number of CU's for each class that is left to complete. Enter Q when done.");
leftCU.add(in.nextInt());

[Code] .....

View Replies View Related

Get User Input For A Char Value?

Jan 9, 2015

I am trying to get user input for a char value and am having some difficulty getting input for a char value.

Java Code:

//imports packages
import java.io.*;
import java.text.DecimalFormat;
class ModuleCulminatingTask {
public static void main (String args []) {
//declares variables
float var3, var4;
long var5 = (int)(Math.random()*10);

[code]....

View Replies View Related

Simple Input Value From User

Apr 10, 2014

I'm not sure what is wrong with my code:

import java.util.Scanner;
public class Main {
int age = 0;
System.out.println("Enter your age: ");
// Read in values
age = in.nextInt();
}

The in is underlined, telling me "cannot find symbol"

View Replies View Related

Getting User Input Second Time

Apr 19, 2014

I'm working on creating a dice game and getting the users input is giving me a really hard time. I have the main game working but this part I'm stuck on. The problem is that it's not giving me the chance to enter the second input when I ask for the game.

//Create Scanner object
Scanner keys = new Scanner(System.in);
//Get chips
System.out.print("How much money would you like to change? ");
int chips = keys.nextInt();
System.out.println("You now have $" + chips + " in chips.");

[code]...

This is what I get when I run it run/How much money would you like to change?

View Replies View Related

2D Array Input User For GUI

Mar 25, 2014

Java Code:

import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
public class SortTable {
public static void main(String args[]) {
Runnable runner = new Runnable() {
public void run() {

[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

Using Wildcards With User Input

May 26, 2014

I have a mysql database and I want to be able to search through a table for a key word in a column like:

words

my fat cat

the yellow canary

what blue cow

and if i put in the full string like "what blue cow" if finds a match, but I want to be able to put in "blue" and see if it finds a match

Java Code:

String keyword = t3.getText();
String sql1;
sql1= "SELECT * FROM table WHERE words ='"+keyword+"'";
rs = stmt.executeQuery(sql1);

while(rs.next()){

JOptionPane.showMessageDialog(null, "found match");
} mh_sh_highlight_all('java');

Im not sure how to do this using wild cards with user input (a JTextfield)

View Replies View Related

Get A String From User Input?

Apr 13, 2014

I trying to get this code to get user input instead of reading from a hardcoded array. I'm getting compile errors while trying to get user input. Here's some of the code:

Java Code: // BubbleSort Java
// compile with: javac BubbleSort.java
// run with: java BubbleSort

[Code]....

View Replies View Related

Value Will Multiply By User Input

Apr 14, 2014

I would like to multiply the amount stated inside program by user input. I currently have

public static void setTicket(double ticket)
{
//if statement for tickets
if (ticket == 1)
Ticket = 10.00;
else if (ticket == 2)
Ticket = 20.00;
else if ( ticket == 3)
Ticket = 30.00;

The user should enter 2 and the value should show 20.00. This does work however im looking for a way to say enter 2 = 2*10 instead of stating each value individually.

View Replies View Related

How To Take User Input As Integers

Jun 2, 2009

Suppose I write a program to multiply two numbers.

The user enters the numbers as follows:

2
3

How do I extract these integers inside main? [Explain the case where the integers are on two separate lines].

What to do for the newline inbetween?

View Replies View Related







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