~~~College Java Program~~~~

Hi would anyone like to help me with my program? This is my first year taking JAVA. I took c++ last quarter. Anyway,
If anyone if really bored or is willing to help, you can get the templates for the program at
http://www.ics.uci.edu/~thornton/2001summer/ics22/LabManual/ElPresidenteHealthCare/StartingPoint/
and the manual on what to do is at
http://www.ics.uci.edu/~thornton/2001summer/ics22/LabManual/ElPresidenteHealthCare/
supposedly its quite simple if you know what your doing...but i dont, so....haha
your help is much appreciated..

first, check that == is not what you want but equals() or equalsIgnoreCase()
if( temp == "physician" )
catalog.add( P1 );
else if( temp == "dentist")
catalog.add( P2 );
else if( temp == "accupuncturist")
catalog.add( P3 );
else if( temp == "surgeon")
catalog.add( P4 );
else
return;
lets say that the person says to a dentist...how do i
continue on to ask the next set of questions? like all
the dentist info to store...and how do i store it
all??1. you could follow a script and ask questions accordingly
2. make classes for each occupation object and delegate the question/answer to that. you may even want to make an abstract or interface called Occupation that has a method startInterview() to kick things off. if there are common questions you might want to use an abstract class rather than an interface.

Similar Messages

  • Java Program.. HELP  (switch statement)

    I need help on fixing this program for school.ive looked at information online but i still do not see what i am doing wrong.
    The College Rewards Program is based on a student�s achievements on the ACT Test. Students that have excelled on the test are going to be rewarded for the hard work that they put into high school and studying for the exam. The following are the rewards that will be given to students. They are cumulative, and they get all rewards below their score.
    1. 35-36 $100 a week spending money
    2. 33-34 Free computer
    3. 31-32 $10,000 free room and board
    4. 25-30 $5000 off the years tuition
    5. 21-24 $500 in free books per year
    6. 17-20 Free notebook
    7. 0-16 Sorry, no rewards, please study and try taking the ACT again.
    Make a prompt so the user is asked for their ACT score( be careful).
    Change the ACT score into a number
    Then have the program use that number to display a message about the Rewards program.
    Sample output:
    What was your score on the ACT: 44
    Entry error, please enter a number from 0 to 36.      (error trap wrong numbers)
    What was your score on the ACT: 27
    You got a 27 on the ACT, your rewards are:      ( have it number the rewards)
    1. $5,000 off the year�s tuition
    2. $500 dollars a year in books
    3. A free notebook
    Congratulations on your hard work and good score.
    import java.util.Scanner;
    import java.text.*;
    public class Act
        public static void main (String [] args)
             Scanner scan = new Scanner( System.in );
              int score,reward;
              score=0;
              boolean goodnum;
              do
                      System.out.println( "What was your ACT score? " );
                              score = scan.nextInt() ;
              if (score >0 || score <36) goodnum = true;      
                   else
                    System.out.println ("Please enter the correct number");
                              goodnum=false;     
                    while (score<0 || score>36) {
                              if (score==35 || score==36) reward=1;
                                   else if (score ==34 || score score==33) reward=2;
                                        else if (score==32 || score==31) reward=3;
                                             else if (score>=25 && score<=30) reward=4;
                                                  else if (score>=21 && score<=24) reward=5;
                                                     else if (score>=17 && score<=20) reward=6;
                                                              else reward=7;
        c=0
        switch (reward) {
        case 1: $100 a week spending money
                  c++
                  System.out.println ("$100 a week spending money");     
        case 2:     Free computer
                  c++
                  System.out.println ("Free computer");     
            case 3:      $10,000 free room and board
                  c++
                  System.out.println ("$10,000 free room and board");
        case 4:      $5000 off the years tuition
              c++
              System.out.println ("$5000 off the years tuition");
        case 5:      $500 in free books per year
              c++
               System.out.println ("$500 in free books per year");
        case 6:      Free notebook
              c++
              System.out.println ("Free notebook");
        case 7:      Free notebook
              c++
              System.out.println ("Sorry, no rewards, please study and try taking the ACT again.");
              break;
        default:
             System.out.println ("Sorry, no rewards, please study and try taking the ACT again.");
            break;
        }

    There are some strange things going on here that could be fixed, so I'll just put my version of how i'd handle this up.
    import java.util.Scanner;
    import java.text.*; // is this really needed? Scanner's the only class I see
    public class Act {
      public static void main( String[] args ) {
        Scanner scan = new Scanner( System.in );
        int score, reward; // don't need to set a value yet
        boolean goodnum;
        do {
          System.out.println( "What was your ACT score? " );
          score = scan.nextInt();
          if ( score >= 0 && score <= 36 ) goodnum = true; // note the && and =s
          else {
            System.out.println( "Please enter a valid number (between 0 and 36)." );
            goodnum = false;
        } while ( !goodnum ); // when this loop finished, the number will be between 0 and 36, a good number
        if ( score >= 35 ) reward = 1;      // save yourself the typing, by now score must be between 0 and 36
        else if ( score >= 33 ) reward = 2; // so just go down with else ifs.
        else if ( score >= 31 ) reward = 3; // this will only reach the lowest point.
        else if ( score >= 25 ) reward = 4;
        else if ( score >= 21 ) reward = 5;
        else if ( score >= 17 ) reward = 6;
        else reward = 7;
        // what was the c for? reward already tells how well they did
        // You handled the switch statement almost perfectly
        // don't break so that reward progressively adds to the output
        if ( reward >= 6 ) { // this if statement is optional, just for good esteem. You could even take it out of the if{}
          System.out.println( "For your score of "+String.valueOf( score )+" you will be rewarded the following:" );
        switch ( reward ) {
          case 1: // $100/week spending money
            System.out.println( "$100 a week spending money." );
          case 2: // Free computer
            System.out.println( "Free computer." );
          case 3: // $10,000 room and board
            System.out.println( "$10,000 free room and board." );
          case 4: // $5000 off tuition
            System.out.println( "$5000 off the year's tuition." );
          case 5: // $500 in free books per year
            System.out.println( "$500 in free books per year." );
          case 6: // Free notebook
            System.out.println( "Free notebook." );
            break; // break here to keep away from discouraging the fine score
          case 7: // since 7 and default are the same result, ignore this and it'll pass to default
          default: // but technically, since reward must be from 1 to 7, default would never explicitly be called
            System.out.println( "Sorry, no rewards. Please study and try taking the ACT again." );
            break; // likely this break is unneccessary
    }That works in my head, hope it works on your computer.

  • Cpu usage in java program

    i have writen a java program and run on unix, the program will create a connection object which connects to a db, and create a scoket to communicate with another machine.
    However, when i use the "top" command in unix and check cpu usage, it used about 35% at the begining, and after few seconds, it drops around 7-8%. May I ask if this is normal? any tips on writing java program which can save more system resources?
    please advice. Thanks

    Hello friend ,
    I am Narayanan from PSNA ENGG College, Dindigul , TN ... I try to find CPU Usage in java and get success.... I am also try form same VC++ file... Try this following steps
    if u wont get mail me::: [email protected]
    Bye
    Steps:
    1. Create java file with name CPUUti.java
              class CPUUti {
              public native void displayCPUUsage();
              static {
              System.loadLibrary("hello");
              public static void main(String[] args) {
              new CPUUti().displayCPUUsage();
    2.compile the program
                   javac CPUUti.java
                   Result: Get Class file
    3.Create header file
                   javah CPUUti
                   Result: Header file CPUUti.h is created
    4.Open the VC++ with Design wizard
              choose Win32 Dynamic Link Libarary
              Give Projectname, location
    5.copy the source file and Header files which you want
    Source files:
                   CpuUsage.cpp
                   Main.cpp
                   StdAfx.cpp
    Header Files:
                   CpuUsage.h
                   PerfCounters.h
                   StdAfx.h
    6. include the Header file CPUUti.h in header file
    7. create new C++ source file getCPU.cpp in the same project
    8.include getCPU.cpp file to the Sourcefile list in the same project
    9.copy this code in to getCPU.cpp
                   #include "CpuUsage.h"
                   #include "CPUUti.h"
                   #include "PerfCounters.h"
                   #include "StdAfx.h"
                   JNIEXPORT jint JNICALL Java_CPUUti_Display
                   (JNIEnv * s, jobject s1)
                        CCpuUsage usageA;
                        CCpuUsage usageB;
                        while (true)
                             // Display the system-wide cpu usage and the "Explorer" cpu usage
                             int SystemWideCpuUsage = usageA.GetCpuUsage();
                             int ProcessCpuUsage = usageB.GetCpuUsage("explorer");
                             printf("System-wide Cpu Usage: %3d%%, Explorer cpu usage: %3d%%\r",SystemWideCpuUsage, ProcessCpuUsage);
                             Sleep(1000);
                        return 0;
    10. copy the headerfiles which is present in the jdk\include and jdk\include\win 32
    paste to the VC++\include\
    11.Build the VC++ file.
    12.DLL file is created inside the Debug\ folder
    13.copy that DLL file and paste it to the java source file location
    Run the java file and enjoy...................

  • Interested in Learning Java Programming.

    Hello All,
    I a college student and I am interested in learning Java programming. Where would be a good place for me to start?
    Thanks

    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.

  • How to implement a print screen through a java program rather than a keyboa

    help needed urgently to make a college project.
    have to capture whatsoever is on the client screen
    and sent it to to a server program where it will be made visible on a frame or panel.
    this is to be done without the client ever knowing it.
    so needed to implement a printscreen command using java code and put it in a program(also how to make
    the .class file containing this code run in the background all the time since the client comp starts till it is shut down without the client ever knowing it)
    e mail: [email protected]

    <pre>
    hartmut
    i need help.
    i've recently started using the web to learn more about java.your reply was very discouraging.
    the proff. just wants a decent project.
    but i want to make this project to improve my java networking skills.
    if you can help , please tell me how to implement a printscreen through a java program rather than a keyboard.
    I'll be very grateful to you if you can help me in this regard, but please dont send a dissapointing response like the previous one.
    mail: [email protected]
    </pre>

  • Which JAVA program should I download?

    I'm new to JAVA, can someone please tell me a good tutorial and program to create JAVA applets on?

    If you're new to Java, I suggest that you start first using simple text editor like Windows Notepad or Edit.com, because it may help you familiarize the Java language. Even though it's time-consuming, its worth, you can have a strong understanding about the Java language.
    You know what I�m having difficulties to say what I wanted to say because you know speaking English is my second language, so, to make it clear what I wanted to say, I will tell you a short story, so you listen...
    "I have a friend (she�s new to Java and she�s studying from other college school), she's using an IDE <software and company name is hidden / protected>, and yes that IDE is absolutely help her save her time developing her java program� the program is finished� time comes� she need to package her program for defense� packaging was successful� but when she run and test her program into one of the school�s computer� her program throws a bunch of exception (<software.company.********Tracker not found>) that isn�t occur when she�s running her program on her own PC (at home). She asked for my help (15mins before defense) and� 50% of the program crippled. I found that that IDE she�s using is semi-propriety and in the end, what happen is her group is assigned for re-defense, her time is not saved it is wasted."
    So be aware of the possible hidden price of time-saving routines and always be aware of what your IDE is doing under the cover. Also, your understanding might be impaired and you might feel helpless when you called on to debug your code in a computer with a minimum of tools without those cute IDE�s. Am I right? Correct me if I�m wrong. God bless you all ^_^
    For tutorial, see reply by kevljo.
    Thank you!

  • Error while running a Java Program

    Can anyone help me,
    I am getting the following error while running a Java program, Below is the exception thrown, please help.
    java.nio.BufferOverflowException
    at java.nio.Buffer.nextPutIndex(Buffer.java:425)
    at java.nio.DirectByteBuffer.putChar(DirectByteBuffer.java:463)
    at org.jetel.data.StringDataField.serialize(StringDataField.java:295)
    at org.jetel.data.DataRecord.serialize(DataRecord.java:283)
    at org.jetel.graph.DirectEdge.writeRecord(DirectEdge.java:216)
    at org.jetel.graph.Edge.writeRecord(Edge.java:288)
    at com.tcs.re.component.RESummer1.run(RESummer1.java:505)
    java.nio.BufferOverflowException
    at java.nio.Buffer.nextPutIndex(Buffer.java:425)
    at java.nio.DirectByteBuffer.putChar(DirectByteBuffer.java:463)
    at org.jetel.data.StringDataField.serialize(StringDataField.java:295)
    at org.jetel.data.DataRecord.serialize(DataRecord.java:283)
    at org.jetel.graph.DirectEdge.writeRecord(DirectEdge.java:216)
    at org.jetel.graph.Edge.writeRecord(Edge.java:288)
    at com.tcs.re.component.RECollectCont.run(RECollectCont.java:304)

    Ok, let's see. Write the following class:
    public class Grunt {
      public static void main(String[] args) {
        System.out.println("Hello Mars");
    }Save it as "C:\Grunt.java", compile by typing:
    javac c:\Grunt.javaRun by typing:
    java -classpath "C:\" GruntDoes it say "Hello Mars"? If yes, go back to your program and compare for differences (maybe you used the "package" statement?).
    Regards

  • Running a java program a set number of times

    This is a general question. Is it possible to make a java program run only 5 times for the sake of arguement.
    Basically I want to write a program that will give the user some flexibility when it will actually run another Java program, but I only want them to be able to say "not now' for a set number of times. When the last time comes the other program will launch. I was initially thinking of the Do Whilw loop, but this needs to work when the program is restarted.
    Program starts, it has 5 times it will run before it does something else(doesn't really matter now I think). User takes option "Not Now" and the program ends, but warns the user this will run 4 more times before you will need to do something.
    This process will repeat until the user takes the option "Ok install now" or the time limit expires and the install occurs anyway. Can someone point me in the right direction.

    ok I see so it's like one those programs that you download for free on the internet and they give you a set amount times to use it before you have to pay for it. but in this case when the number of times you use it equals 5 (or when the user clicks ok) a different java app will open automatically.
    My first thought would be to Write a Serialized object to disk using objectOutputStream that stores the number of times the application has been opened. and each time the program runs it checks for the serialized object and then you can do something like what I posted before. of course if were worried about security the user could always look for the object and erase it, if so then I guess we would have to come up with another plan of attack
    Hope this helps

  • Running a java program

    This shows how dumb i am.
    I have a java program all wrote. How can i run it without using the compiler? Can i have a .exe file or something that I just have to click on to run??
    Thanks again
    Agdude

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\awaguespack>cd jbproject\untitled1\classes\untitled1
    C:\Documents and Settings\awaguespack\jbproject\untitled1\classes\untitled1>java
    form
    Exception in thread "main" java.lang.NoClassDefFoundError: form (wrong name: unt
    itled1/form)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    C:\Documents and Settings\awaguespack\jbproject\untitled1\classes\untitled1>dir
    Volume in drive C has no label.
    Volume Serial Number is C065-81CA
    Directory of C:\Documents and Settings\awaguespack\jbproject\untitled1\classes\
    untitled1
    07/24/2003 02:21 PM <DIR> .
    07/24/2003 02:21 PM <DIR> ..
    07/24/2003 02:21 PM 7,655 form.class
    1 File(s) 7,655 bytes
    2 Dir(s) 36,031,016,960 bytes free
    C:\Documents and Settings\awaguespack\jbproject\untitled1\classes\untitled1>echo
    %classpath%
    %classpath%
    C:\Documents and Settings\awaguespack\jbproject\untitled1\classes\untitled1>

  • Running a java program at "Start Up"

    Besides running an html file with an applet in it. Are there any simple ways to launch a java program every time the computer is turned on.
    I am not asking for specific directions, but rather just an idea, and i will go find my own guide.

    Well two ideas (if ur on windows) u could try are -
    one, if you had a class file you could simply create a
    batch file on windows that says java <class> and then
    put that batch file in your startup so that the class
    is run at startup or else you could think of modifying
    the registry keys on windows to run this class at
    startup - whichever works for you.Or you could just jar the program up, adding a Main-Class indicator in the manifest, and then add a shortcut to the jar to the startup folder, as someone else stated. Theres little need to go messing around with DOS batch in modern windows.

  • Running a java program from an icon

    I want to run my program from an icon on my desktop. I have a .bat file that I've built a shortcut to and it works.MY GUI program does display and run when I click on the icon. The problem is that the DOS window also shows up behind my GUI.
    Is there anyway to prevent the DOS window from showing? Or is there another way to run a Java program without resorting to a DOS command line or running it through FORTE or another IDD?

    Chris's solution worked well, with one small problem. Once my GUI starts, it takes up the whole screen. Normally when I run it, it appears as a small window.
    not a big problem, I can reduce it easily after it starts. But does anyone know a way to make it come up in the reduced size it norally comes up in when I run it from my IDE?

  • Running a java program via a batch file

    I am unable to run a java program from a batch file that I created.
    spiderpackage.EntryPoint is a class file which I am trying to run with a -v option to output something.What should I do to get the output?
    echo ^<html^>^<body^>
    echo hello^<br^>
    call java spiderpackage.EntryPoint -v
    echo ^</body^>^</html^>

    This has nothing to do with java programming. Have a look at the windows help for the call command.
    The echo <html> stuff doesn't make sense. What's it for?
    The command in you batch file should be:
    java -cp . spiderpackage.EntryPoint -v
    assuming that java is in the system path, and the EntryPoint.class is in a directory called spiderpackage which is a subdirectory of your current working directory

  • Running a Java program at startup in Linux

    Hello
    How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
    Thank you,
    Mihai

    This is really a Linux question, not Java.
    And then it depends on the version of Linux you are using.
    Maybe this will help, otherwise you should try on a forum for your version of Linux.

  • Running a java program in a directory other than the current directory

    How do I run a java program that's located in a directory other than the current directory?
    There is a file Test.java in /dir1/subdir1. If my current directory is anywhere other than that directory, say /dir2/subdir2, I can compile Test.java by using:
    javac -classpath /dir1/subdir1 /dir1/subdir1/Test.java
    But when I try to run it with:
    java -classpath /dir1/subdir1 /dir1/subdir1/Test
    I get a java.lang.NoClassDefFoundError: \dir1\subdir1\Test
    Any thoughts?

    You need to specify just the name of the class you want to run. So java -classpath /dir1/subdir1 Test

  • Running a java program outside eclipse...!

    Hi guys...!
    I wrote a java program that uses different classes. The program deals with xml documents and creates a new xml document. The problem is, the program works fine in eclipse, but when I run through the command line in windows, it complains that it can't see the different classes that I created. Here is one of the error messages:
    Test.java:44:cannont find symbol
    symbol : class Circuit
    location : class src.Test
    Circuit cir = new Circuit ();
    Note: Test.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details
    Does anyone know how to resolve this...?
    Any help from you guys will be very appreciated.
    Thanks..

    I think the problem is probably something like this:
    You have a path thus:
    C:\blahblahblah\With a subdirectory thus:
    C:\blahblahblah\srcIn which you have declared classes thus:
    package src;
    public class Foo {
    }And you have then used a classpath something like the
    following:
    javac -classpath C:\blahblahblah\src Foo.javaThis is incorrect. Your classpath needs to point to
    the root of the package hierarchy. If it's like the
    above, it will look in C:\blahblahblah\src for a
    package src, which results in a path like
    C:\blahblahblah\src\src which does not exist.
    You should set it to:
    C:\blahblahblah\Where that is the root from which your packages
    stem.
    Dave.Thanks Dave. It works man. I really appreciate your help.

Maybe you are looking for

  • Header in the output of the program

    I have used this code for creating header in the output. REPORT  ZF7U_PAYMT_PAR         LINE-SIZE  132         LINE-COUNT 60         NO STANDARD PAGE HEADING. TOP-OF-PAGE. CALL FUNCTION 'Z_STANDARD_PAGE_HEADER'        EXPORTING             COMPANY_CO

  • Execute sql task case statement

    hi  select increment = case when len(max(id) = 1 then "0000" + max(id) when len(max(id)) = 2 then "000"+ max(id) end  from filesequence i am getting error incorrect syntax near then how to use above code properly

  • Backup database using RMAN

    Hi, I wanted to perform the first backup with RMAN and I used this command and I got error: RMAN> BACKUP AS COPY DATABASE; "can not backup or copy active file in noarchivelog mode". But in order to turn on the log_mode to ARCHIVELOG, first I need to

  • Go You Go Back To iDVD 6?

    Hello Having all kinds of trouble opening iDVD 6 projects in iDVD 8. They just won't open. I've upgraded to iLife 08 (totally). I wonder if I can delete all the iLife 08 app files and re-install iLife 06? Thanx

  • F1 help for documentation

    hi , F1 help for internal table field, please let me know the process. Example: matnr for material number from mara table, i mean to say user documentation , it can understands easily for customer. Any one have exmple code please let me know.