Go Back   Tech Support Forum > The IT Pro > Programming

        
Join Tech Support Forum Today

Reply
 
Thread Tools Search this Thread


Old 11-17-2011, 03:48 AM   #1
Registered Member
 
Join Date: Sep 2011
Posts: 4
OS: win7


Post Help Java Program

Help me with my program My Professor Want me to do a Program that will Make the Program To Try Again.. i wanted to be able to make it go from the start of the program again, instead of inputting the program again, basically like a restart command. anyone help?
thanks

This my code :
Code:
import java.util.Scanner;
    public class Prog2 {
    public static void main(String[]args) {
     
    Scanner input = new Scanner(System.in);
     
    int highestNum=0;
    int lowestNum =5000;
    int num, numTimes;
     
    System.out.println("How many numbers would you like to enter? ");
    numTimes = input.nextInt();
     
    for (int c=1; c <= numTimes; c++) {
    System.out.println("Please enter an integer !");
    num = input.nextInt();
    if (c == 1) {
    lowestNum = num;
    highestNum = num; }
    else {
    if (num < lowestNum) {
    lowestNum = num; }
    if (num > highestNum) {
    highestNum = num; }}}
    System.out.println("The higest number is " + highestNum);
    System.out.println("The lowest number is " + lowestNum);
    }
}

__________________
DarkFire08 is offline   Reply With Quote
Old 11-17-2011, 10:32 AM   #2
TSF-Emeritus
 
Ninjaboi's Avatar
 
Join Date: Dec 2010
Location: U.S.A., Texas
Posts: 2,047
OS: Windows XP SP3, Ubuntu 10

My System

Re: Help Java Program

Unfortunately, we are unable to help you with homework/school assignments as per the TSF rules stating:

Quote:
You may not ask for assistance with homework assignments, projects or book reports for school college or university
We can however give you a push in the right direction.

You should try Googling "Java Do-While Loop" and get some example code. Remember, Google is your friend.

__________________
Ninjaboi is offline   Reply With Quote
Old 11-19-2011, 05:22 PM   #3
Registered Member
 
Join Date: Apr 2010
Posts: 236
OS: Windows 7

My System

Re: Help Java Program

Although, as Ninjaboi said, we're unable to help you with homework assignments, there's a code tag for posting on forums. It's usually expected, and helpful for people reading the code.

Something like:
Code:
#Printing "Hello World!" in Python
print('Hello World!')
You do it like "code" with a /code (surrounded by [])
__________________
Crockeo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is on
Smilies are on
[IMG] code is on
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple Java EXCEPTION_ACCESS_VIOLATION notices digit ally General Computer Security 6 10-24-2011 01:17 PM
Red signs, antivirus program gone crazy scott98 Windows XP Support 5 07-04-2011 05:26 AM
Please Help JAVA Related Errors rowell PC Gaming Support 2 04-10-2011 11:52 PM

Post a Question




All times are GMT -7. The time now is 04:06 PM.


Copyright 2001 - 2012, Tech Support Forum

Windows 7 - Windows XP - Windows Vista - Trojan Removal - Spyware Removal - Virus Removal - Networking - Security