Getting Program To Repeat Itself In JGRASP Without Having To Click Run

Oct 10, 2014

Basically, I have want to keep typing numbers and pressing enter and the same program keeps repeating itself. This is the code I need to repeat,

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

[Code] .....

View Replies


ADVERTISEMENT

How To Repeat Program

Feb 7, 2015

I have done a rock, paper, scissors program, but it only executes once. How do I make the program repeat so you can play multiple times?

import java.util.Scanner;
import java.util.Random;
public class RockPaperScissors {
public static void main(String[] args) {
 
int A;
 
Scanner input = new Scanner(System.in);
Random random = new Random();

[code]....

View Replies View Related

How To Get A Program To Repeat X Amount Of Times Automatically

Oct 27, 2014

Ii am trying run a do while loop on java a specific amount of times for example if i were to type in "Enter number of years" and enter 4. i need the loop to execute 4 times or if i said 6 times then i would be 6. the program i have repeats it and takes it back to reentering "Enter number of years" i need it to execute by its self x amount of times. here is what i have so far

System.out.println("Enter the number of years: ");
years = keyboard.nextInt();
rainfall = generator.nextInt(10) + 1;
System.out.println("Year " + "rainfall amounts were");;
for (int months = 1; months <= 12; months++)

[Code]...

View Replies View Related

How To Write A Program Using Quadratic Formula In JGrasp

Mar 4, 2015

Write a program named QuadraticTable.java that takes three double arguments and two int arguments (in that order) from the command line. The three doubles will represent a, b, and c from the quadratic formula.

If the discriminant is non-negative, find and print the solutions to the quadratic equation. (The plus/minus sign in the quadratic formula indicates that you would separately perform both operations). Otherwise print "no real solutions".

Then using the last two int arguments as x_min and x_max, print a table of x and ax

2 + bx + c

values using the a, b, and c read in as command line arguments.

Sample output: (command line arguments were 1 0 2 -3 3)

1x^2 + 0x + 2 has no real solutions.

X 1x^2 + 0x + 2

-3 11

-2 6

-1 2

0 2

1 3

2 6

3 11

View Replies View Related

JGrasp - Writing A Program For Ticket Sales

Sep 13, 2014

The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets: box, sideline, premium, and general admission. After each game, the data is stored in a file in the following format:

ticketPrice numberOfTicketsSold

Sample data might look like:

250 5750

100 28000

50 35750

25 18750

The first line indicates that the box ticket price is $250 and that 5750 tickets were sold at that price.

Your program should input in this data (using Scanner or an input dialog box), then output that data to a message dialog box along with total ticket sales information. Output the total number of tickets sold and the total sale amount. Make your output user-friendly and "pretty". Format your output with two decimal places. Use JOptionPane and the formatting techniques learned in chapter 3 for your output. Example output might be:

5750 Box Tickets sold at $250.00
28000 Sideline Tickets sold at $100.00
35750 Premium Tickets sold at $50.00
18750 General Admission tickets sold at $25.00

View Replies View Related

Program Repeat Until User Enters Number 4 To Exit?

Feb 18, 2014

My question is how can I make the program repeat until the user enters the number 4 to exit?
 
/**
* Write an application for a furniture company; the program determines the price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany. The output is the name of the wood chosen as well as the price of the table. Pine table cost $100, oak tables cost $225, and mahogany table cost $310. Also ask the user to specify a

(1) large table or a
(2) small table.

Add $35 to the price of any large table and add nothing to the price for a small table. Display the output. Your program must repeat until the user chooses to exit.

*/
import java.util.Scanner;
public class Wood {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println ("Table Prices");

[Code] .....

View Replies View Related

JGrasp - Errors In Writing A Program For Checking And Savings

Sep 19, 2014

Here is the objective of the assignment:

Quote : A bank in your town updates its customers' account at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customer's balance falls below the minimum, there is a service charge of $10 for savings accounts and $25 for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows:

- Savings accounts receive 4% interest.

- Checking accounts with balances of up to $5000 more than the minimum balance receive 3% interest; otherwise, the interest is 5%.

Write a program that reads a customer's account number (integer), account type (character: s for savings or c for checking), minimum balance that the account should maintain, and the current balance. The program should then output the account number, account type, current balance, and an appropriate message.

Your program should only allow 'c', 'C', 's', or 'S' as valid input, any other character for the account type should result in an error message. Format your monetary output to two decimal places, and use constants for all the above constant values.

Sample output:
Please enter your account number (int), account type (char), minimum balance, and current balance:
46728 S 1000 2700
Account Number: 46728
Account Type: S
You have earned 0.04 interest on your account.
Current Balance: $2808.00

[Code] .....

Invalid account type!

View Replies View Related

Ask User For Number Of Rows / Give Option To Repeat The Program

Aug 11, 2014

This is what I have so far, but how do I ask the user for the number or rows and give the user the option to repeat the program?

public class Pyramid {
public static void main(String[] args) {
int myLevel;
int i, j , k;
myLevel = 6;
for (i = 1; i <= myLevel; i++) {

[Code] ....

View Replies View Related

Program Exits Even When Click No Or X Button On Upper Corner

Mar 31, 2015

Here is the snippet of code that is causing the problem

Java Code:

addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent e)
{
int confirm = JOptionPane.showOptionDialog(
VendorMachineSimulation.this,
"Are You Sure you want to close this application?",
"Exit Confirmation", JOptionPane.YES_NO_OPTION,

[Code] ....

My question is why does the snippet code at the top works in the class processAction but when I add to the main class that extends JFrame, it exits regardless if I click yes, no or the x button.

View Replies View Related

JSF :: Row Index In UI - Repeat Tag

Feb 7, 2009

I am using ui:repeat tag to iterate over a list. Now in that I need to do some processing based on the current iteration index like we have in a normal for loop. I have to do some processing based on the current iteration index. How can I get that.

View Replies View Related

Set 10 Min Timer For Repeat?

Aug 19, 2014

i have a client side program that grabs information about the computer it runs on. I want to have it grab the same info every so often, and check it against the original.

what can be used to do something like that? end game would be having it start up with the pc, then check periodically. if the values are different, send them to the database

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

Rock Paper Scissors Repeat Itself 10x

Feb 18, 2014

I was wondering how I could make this code for rock paper scissors repeat itself 10x
 
import java.util.Scanner;
import java.util.Random;
public class Rock {
public static void main (String [] args) {
 
[Code] .....

View Replies View Related

How To Make Jar Of Project With JGrasp

May 12, 2014

I'm done with my project and I'm not trying to make it into a jar with JGrasp... I start by making a project then I click the option to make my project into a jar... Everything works but when I try to run it it says that the main class cannot be found... How can I fix this?

View Replies View Related

How User Enter Data Into JGrasp Without Using GUI

Oct 7, 2014

I'm currently taking a Java Programming module in college, the program we are using is jGrasp and I'm currently stuck on one aspect of the language.

I did VB last year and I enjoyed it and got good grades so I'm comfortable with Java in terms of compiling the code correctly and getting it to run with no errors.

But for a project we got yesterday, the user must be able to enter data (e.g. an answer) into jGrasp without using a GUI. This is the case because we won't be dealing with GUIs until next semester.

I'm able to handle the rest of the project, but the part which I can't figure out is how the user can interact with jGrasp without the aid of a GUI.

View Replies View Related

JGRASP Won't Allow To Declare Variables As Strings

Oct 10, 2014

Java Code:

import java.util.Scanner;//Imports Scanner
public class operadoreslogicos//imports a public class {
public static void main (String [] args)//defines the state of a class {
Scanner input = new Scanner (System.in);//Inputs a scanner to read user
//keyboard
boolean cierto = true,// Declares variables as boolean and applies a value

[Code] .....

The word string is supposed to turn purple when I type it, but it just stays normal, so it doesn't declare hello and bye as variables.

View Replies View Related

File Paths In Eclipse / Jgrasp

May 1, 2014

So I downloaded jgrasp and eclipse on a new computer and am trying to figure out how their filing/path system works.In eclipse I created a new project under which I've imported all my files for my comp sci class, so they're all under this one project which is my only project. I attached a pic of what my eclipse workspace looks like. In this project folder is a file I'm trying to run.

I keep getting an error saying "editor" does not contain a main type.When I change my class name to the project folder I end up getting an option to run the program as an applet or an application, but either one I choose I get the same error message. In the bottom it gives me a warning saying

DescriptionResourcePathLocationType
Build path specifies execution environment CDC-1.1/Foundation-1.1. There are no JREs installed in the workspace that are strictly compatible with this environment. CS1050AssignmentsBuild pathJRE System Library Problem

I tried running the program in jgrasp and got this error

----jGRASP wedge2 error: command "javac" not found.
---- This command must be in the current working directory or
---- on the current system PATH or jGRASP PATH to use this function.
---- System + jGRASP PATH is "C:UsersQudrat.MommandiDocuments;C:Windowssystem32;C:Program Files (x86)InteliCLS Client;C:Progra

[code]...

I have the JDK installed in program files, I have the correct versions of eclipse and Jgrasp, and have uninstalled / reinstalled the JDK/Jgrasp/Eclipse so I don't know what the problem is?

View Replies View Related

Compile Error When Running JGrasp

Feb 3, 2015

I keep getting the error Admit.java:10 cannot find symbol

import java.util.*;
public class Admit {
public static void main(String[] args) {
sayIntro();
Scanner console = new Scanner(System.in);
System.out.println("Information for applicant #1:");
getScore(console);
getGPA(console);

[Code] ....

The compiler then reads:

Admit.java:10: error: cannot find symbol
score1(ACTScore, SATScore, GPAScore);
^
symbol: variable ACTScore
location: class Admit
Admit.java:10: error: cannot find symbol

[Code] .....

10 errors

View Replies View Related

JGrasp - Printf Left Justify?

Sep 6, 2014

We're learning printf with JGrasp as the environment at the moment. Heres the problem.

I have a string as this:

String header1 = new String ("Caswell Catering and Convention Service");

as for the printf line, its this:

System.out.printf ("%-5s/n", header 1);

The output is right justified no matter the use of the "-" or without and I can't seem to find the correct thing to do to make it left justified.

View Replies View Related

How To Write Random Number Generator That Will Not Contain Any Repeat Value In A Range

Apr 24, 2015

I am trying to write a Random Number Generator that will not contain any repeat value in a given range

something this I have try so far

import java.util.Random;
/**
* This class is used to generate a
* Range of Random Number in a range from int a to int b
*/
public class RandomNumberGenerator {
public static void main(String[] args) {
int[] arr=randomNummbers(1, 20);
for(int j=0;j<arr.length;j++){

[Code]...

although this code generate random numbers but some values are also getting duplicate.So how to write a program for random number that will not repeat any integer in range?

View Replies View Related

JGrasp - No Main Method / Applet Or IMDlet

Sep 30, 2014

I have been trying to get this code to work but in jGrasp it give the no main method, applet, or IMDlet. The assignment states: Design a class Message that models an e-mail message. A message has a recipient, a sender, and a message text. Support the following methods:

-A constructor that takes the sender and recipient
-A method append that appends a line of text to the message body a method toString that makes the message into one long string like this:

"From:Harry Morgan
To: Rudolf Reindeer. . ."

Write a program that uses this class to make a message and print it. package emailmodel;

import java.util.Scanner;
public class Message
{
private String senderemail;
private String receiveremail;

[code]....

View Replies View Related

How To Remove Value Or Highlighted On Click

Jan 16, 2015

I want my jSpinner value "0" to be removed on button click. and I want my jSpinner and jFormattedTextfield and jTextfield value "0" to be Highlighted(e.g: like highlighted by mouse double click) on button click.By removed I mean: nothing to be in the jSpinner. empty as any textfield. the jSpinner default value is 0 and on Click I want the value of the jSpinner to be removed and Highlighted, I need both examples code.

View Replies View Related

JTabbedPane Tab Click Simulation

Mar 31, 2015

Is it possible to programmatically simulate a click event on a tab (JTabbedPane) to trigger its changeListener once a button is clicked ?

View Replies View Related

Run Another Class By Button Click

May 4, 2015

i have two classes, one is a GUI program and the other is an index writer program. the GUI program uses a j file chooser to select directories and display them in the text fields.the index writer is supposed to take the directories in the text fields and read from one(document location) and write into the other(index location) i want to run the index writer program by the click of a button(indexfbuton) in the gui programi have been able to get the directories to display in the text field but when i click the button to run the index writer class, nothing happens..here is the GUI class

package upload1;
import upload1.IndexFiles;
import java .awt.*;
import java.awt.event.*;

[code]....

View Replies View Related

Impossible To Click Button Twice

Apr 8, 2013

I have been trying to develop a small desktop application. I have JFrame and a button. When I click the button, the app is supposed to save record to database. But it is impossible to click the botton twice. To explain in detail: when a user fill in the form and click the button, the app will warn the user if he/she haven't fill in the appropriate JTextFields. After warning it is impossible to click the button again. I mean after first click, the button is busy and impossible to click.

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;

[Code] ....

View Replies View Related

Applets :: Subtraction And Multiplication With One Click?

Mar 21, 2014

This is what I ended up with and it is not what I want.

How do I convert this to an applet that would run independently on a desk top out of all these shells?

[URL]

View Replies View Related







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