I have a assignment to do some Lexigraphic ordering. I have figured how to get the majority of this done, however, when I input my string values. No output takes place? :s
import java.util.Scanner; public class Lab03c { public static void main(String[] args) { // TODO Auto-generated method stub Scanner lexi = new Scanner (System.in); String s1,s2;
import java.io.IOException; import java.util.*; public class Guesser { public static void main(String[] args) throws IOException { char[] alphabet = "abcdefghijklmnopqrstuvwxyz1234567890 .,:;'-".toCharArray();
[Code] .....
I'm writing a program which will take a three letter word (for now) and then try to guess the word over and over again until it finds it, then print the word and the amount of tries it took to find it.
The problem: at the moment the program will find the word but not break out of the for loop when it does. I think it doesn't like the char to String conversion somewhere along the line.
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.
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.
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.
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;
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;
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");
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
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>();
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
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 {
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:
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?
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.
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;
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: " );
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();
I have a project requiring me to build a program having a user input 3 words, sort them alphabetically and output the middle word. I have done some searching and seem to only come back with results for sorting 2 words. I so far have code to get the user input but I am completely lost as to how to sort them alphabetically.
import java.util.Scanner; //The Scanner is in the java.util package. public class MiddleString { public static void main(String [] args){ Scanner input = new Scanner(System.in); //Create a Scanner object. String str1, str2, str3; System.out.println("Please enter three word words : "); //Prompt user to enter the three words
[Code]...
we havnt done arrays yet and I THINK i have to do compareTo.....how to use it?
I'm having some trouble with getting this program to read an input of morse code and then produce an output of English. When typing in morse code for the phrase 'the string', the output looks something like this:
This specific assignment requires me to write a program that calculates the total sales after each football game. There are 4 types of tickets: box, sideline, premium, and general admission. After each game, data is stored in a file... then output the number of tickets sold and total sale amount. Format your output with 2 decimal places.
Okay I know there is a I/O section and wasnt sure where to post this. I need some insight on how to use file input and output as well ... Here is my program:
import javax.swing.JOptionPane; import java.text.DecimalFormat; public class ticketsSold { public static void main(String[] args) { String BoxSeat; String SideLine;