I want to search for files using wildcards. After a lot of googling I found [URL] ..... I downloaded the .java files and put them in the same directory as my own java file. but now I don't know, how to include this java file.
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".
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;
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()); } }
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????
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.
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
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[])
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());
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?
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.
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:
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.
I have a program that asks you for your password and if it is incorrect it reduces your attempts until you are at zero, but I want to be able to tell the user what passwords they have attempted when they run out of attempts. I've tried a couple of things but how to get it to work. This is my code:
import javax.swing.JOptionPane; public class PasswordV4 { //Begin Class public static void main(String[] args) { //Begin main program //initialize variable int passwordAttempt = 5; int value = 0;
I am new to java and I am trying to write a program where someone has to guess the number. The correct number is 3. If they are below three. It tells them that they are too low and to guess again. If they are too high, it tells them they are too high and to guess again.
However, I am having problems once they enter a number and they get the response "The number was too low. Try again" as it lets them try again but doesn't tell them if it's right, wrong, or too high. I'm not sure what piece of code I am missing. Here is what I have so far:
import java.util.Scanner; public class Guessthenumber { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter a number between 1-10."); double value = input.nextDouble(); if(value == 3)
My project is a program that uses methods to display strings in a variety of different ways. I already have all of that working, my problem is checking for user inputs.For example on the menu portion of my program i ONLY want the user to input 1-5.here is the method i developed for checking user input IT DOES CONTAIN ERRORS this is where i am having troubles.
public static int checkInput(String prompt, int lowerBound, int upperBound) { int input = 0; boolean done = false; while ( !done ) { System.out.println(prompt); if (input.hasNextInt())
[code]....
here is the rest of my program which is working fine besides the checking input. i would like to implement this method for checking inputs into all places where the user is asked to input something.
import java.util.Scanner; public class DisplayingStrings { public static void main(String[] args) { Scanner input = new Scanner(System.in); int getNum = checkInput("Enter #(1-5)", 1, 5); System.out.println("--String Writer--"); System.out.print("Enter a string: "); String word = input.next(); displayMenu(word);
I need to get users input from jtextfield and set it to JTable. This is my code:
public class Projektni extends JFrame { public final JTextField ime = new JTextField(10); public final JTextField prezime = new JTextField(10); public final JTextField index = new JTextField(10); public DefaultListModel podaci = new DefaultListModel(); JButton imeB=new JButton("Upisi u tabelu");
I have to take a users input. The general gist of the problem is I want to convert a decimal number entered by the user inputs into it's binary equivalent....the conversion part I know how to do.
I'm stuck at the user input phase. If the user inputs a decimal number within the correct range (lets say between 0-5000 for this example) the conversion goes ahead as planned and the program outputs on the screen the binary equivalent.
If on the other hand the user inputs a number outside of this range ... OR a String OR and empty space, an error message is given and the user is asked to try again. I don't know how to handle it if the user enters the different types...int or String.
I am using jdk 6 ... I came to know that how we can read strings from user input ... and how we can convert a string to int .. but i dont fount how to read a character by character from user ..
I'm doing a problem where someone will input a name and it will show their title or vice versa. It works fine when the user inputs the name but whenever they input a title it is coming back not found. Not sure what I did wrong.
import javax.swing.*; import java.awt.*; import java.awt.event.*; @SuppressWarnings("serial") public class JEmployeeTitle2 extends JApplet implements //class extends JApplet and AL. ActionListener