Program for a user to enter grades...having a problem

I have a project I am doing for class...this is what i have to do.
"Your instructor needs a program that will input the letter grades of students and perform the following calculations along with the corresponding output: 1.) compute and print a letter grade distribution (makes a chart showing the number of each grade made), 2.) compute and print the class gpa, and 3.) print a bar graph of the letter grade distribution. Program should work for any class size, and should work for any number of classes (dunno what that is talking about)."
the bar graph is just stars printed horizontally using the numbers from part 1.
i have this so far and i'm getting an error at the switch statement saying i'm using a string when i should be using an int, that's problem 1. I'd also like to take some suggestions on a better way of doing this without it getting complicated (we've just gotten to writing our own classes, no array lists or anything "fancy".
import java.util.Scanner;
public class Grades
    public static void main (String [] args)
        Scanner scan = new Scanner (System.in);
        int qualPoints = 0, totalGrades = 0, aCount = 0, bCount = 0, cCount = 0, dCount = 0, fCount = 0;
        double gpa = 0;
        String grade;
        System.out.println ("Enter the student's grade, z to stop.");
        grade = scan.next();
        while (grade.equalsIgnoreCase ("A") || grade.equalsIgnoreCase ("B") || grade.equalsIgnoreCase ("C") || grade.equalsIgnoreCase ("D")
                || grade.equalsIgnoreCase ("F") && grade != "Z" && grade != "z")
                    *switch (grade)*
                        case 'A':
                            qualPoints = (qualPoints + 4);
                            totalGrades++;
                            aCount++;
                            break;
                        case 'B':
                            qualPoints = (qualPoints + 3);
                            totalGrades++;
                            bCount++;
                            break;
                        case 'C':
                            qualPoints = (qualPoints + 2);
                            totalGrades++;
                            cCount++;
                            break;
                        case 'D':
                            qualPoints = (qualPoints +1);
                            totalGrades++;
                            dCount++;
                            break;
                        default:
                            qualPoints = (qualPoints +0);
                            totalGrades++;
                            fCount++;
                    System.out.println ("Enter the student's grade, z or Z to stop.");
                    grade = scan.next();
                gpa = (double) (qualPoints / totalGrades);
                System.out.println ("The class gpa is " + gpa);
        }

had to go watch the Indians lose, unfortunately :P
OK, got the switch to work (or at least be error free). But it's screwing up on the addition (it's giving me a run-time error and stopping the program.
import java.util.Scanner;
public class Grades
    public static void main (String [] args)
        Scanner scan = new Scanner (System.in);
        int qualPoints = 0, totalGrades = 0, aCount = 0, bCount = 0, cCount = 0, dCount = 0, fCount = 0;
        double gpa = 0;
        String grade;
        System.out.println ("Enter the student's grade, z to stop.");
        grade = scan.next();
        char gradeCh = grade.charAt(0);
        while (grade.equalsIgnoreCase ("A") || grade.equalsIgnoreCase ("B") || grade.equalsIgnoreCase ("C") || grade.equalsIgnoreCase ("D")
                || grade.equalsIgnoreCase ("F") && grade != "Z" && grade != "z")
                    switch (gradeCh)
                        case 'A':
                            qualPoints = (qualPoints + 4);
                            aCount++;
                            break;
                        case 'B':
                            qualPoints = (qualPoints + 3);
                            bCount++;
                            break;
                        case 'C':
                            qualPoints = (qualPoints + 2);
                            cCount++;
                            break;
                        case 'D':
                            qualPoints = (qualPoints +1);
                            dCount++;
                            break;
                        default:
                            qualPoints = (qualPoints +0);
                            fCount++;
                        totalGrades++;
                    System.out.println ("Enter the student's grade, z or Z to stop.");
                    grade = scan.next();
                gpa = (double) (qualPoints / totalGrades);
                System.out.println ("The class gpa is " + gpa);
    it's highlighting the gpa = statement at the end giving me a divide by zero error...is the totalgrade statement not working?
and i tried it with lowercase grades and uppercase, only gave me the error on uppercase, but on lowercase it is coming back with a gpa of 0...which wasn't correct.
and thx for the help so far :)

Similar Messages

  • How do you set default programs for all users when deploying Windows 8.1?

    I have my Windows 8.1 image set up the way I want including the start screen, theme, etc. But how can I set the default programs for all users. Most of out computers are non-touch and I want the desktop apps (e.g. Windows Photo Viewer), not the store apps
    to be the default for opening pictures, videos, etc. Can that be done?

    Great question, this has been bugging me too!
    So, I did some research by using "Set Default Programs" app in Windows 8. Then I ran the super ProcMon.exe tool from Sysinternals.com <Thanks Mark!>
    After filtering out the junk, I could see some *interesting* writes to the registry:
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserChoice]
    "Hash"="57y87/ogggU="
    "ProgId"="PhotoViewer.FileAssoc.Jpeg"
    But the "Hash" part had me concerned. I did some internet searching for the hash, and came across a post and a pointer to a blog with some answers.  This is both good news and bad.
    Background:
    One of the problems with Windows XP is that any program can come in and party on the entire system. No, I don't want you to put a shortcut on the desktop, install a crappy IE Toolbar, and change the default file association for *.jpg files to your app, I
    just wanted to play a stupid game. Since Windows 7, Microsoft has been attempting to block that functionality from the stupid applications, and give them back to the user. Take note of the last line in the ITaskbarList3 interface:
       Applications cannot programmatically pin themselves to the taskbar. That functionality is reserved strictly for the user.
    Of course that sucks for us IT Pros who may wish to create *default* working environments for corporate images, but there are some tricks we can do.
    Solution:
    This blog appears to have the answer:
    http://blogs.technet.com/b/mrmlcgn/archive/2013/02/26/windows-8-associate-a-file-type-or-protocol-with-a-specific-app-using-a-gpo-e-g-default-mail-client-for-mailto-protocol.aspx
    New for Windows 8 is a dism command: /Get-DefaultAppAssociations that allows you to export a control case from a known good computer. Microsoft the supports importing the exported xml file via GPO. For example, before I changed the file association, .AVI
    was pointing to the Modern App, after the change the /export-DefaultAppAssociations shows change to the new app:
    From:
    <Association Identifier=".avi" ProgId="AppXhjhjmgrfm2d7rd026az898dy2p1pcsyt" ApplicationName="Video" />
    To:
    <Association Identifier=".avi" ProgId="VLC.avi" ApplicationName="VLC media player" />
    I am still doing some investigation to see if a GPO is required, or if you can inject the association into a local user account. Also, if you do have some Modern Windows 8 Touch Tablets, it would recomend keeping most of the Modern App defaults in place,
    perhaps seperate GPO's for Desktops/Laptops vs Tablets?
    -k
    Keith Garner - keithga.wordpress.com

  • BADI for MIGO for restricting User to entered other MVT types?

    Hi All,
    BADI for MIGO for restricting User to entered other MVT types?
    I want to restrict some of user not to use 501 Movement type ..I already created a Ztable for checking User for 501 type.
    Please let me know any Enhancement to be used to restrict user ?
    Thanks and Regards
    Steve

    Hi Steave,
    You can use this enhancement exit MB_CF001, this exit will be called every time before posting, you can use your logic in this exit. see its documentation first before implementing.
    Regards
    Ahsan

  • AppleScript: Waiting for a user to enter user name and password

    I'm currently working on an AppleScript designed to automate binding a computer to Active Directory and another script to install a login certificate. While you can create a UNIX shell script for the Active Directory binding, I found that you have to have your user name and password in the script itself and this system will be deployed by multiple people.
    So instead I'm doing an GUI Automation AppleScript of Directory Utility. What I'd like to do is have the script to wait for the admin user (who will be remoting in by ARD) to enter their Network user and password, click okay and then continue the script to quit the program and then run a self-destruct (which I'd also appreciate any advice about doing in AppleScript)
    Here's the script so far, which I've set up successfully:
    activate application "Directory Utility"
    tell application "System Events"
      click text field 1 of row 1 of table 1 of scroll area 1 of group 1 of group 1 of window "Directory Utility" of application process "Directory Utility"
      click button 1 of group 1 of group 1 of window "Directory Utility" of application process "Directory Utility"
      click text field 2 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "EXAMPLE.COMPANY.com"
      click UI element 3 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click radio button "Administrative" of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click checkbox "Allow administration by:" of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 1 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExamplePS NA"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 2 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExampleNA"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 3 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExampleNATemps"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 4 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExampleTeam 1"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 5 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExampleTeam 2"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 6 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExampleTeam 3"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 7 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExampleDesktop Admins"
      click button 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      click row 8 of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Directory Utility" of application process "Directory Utility"
      keystroke "GroupExampleDomain Admins"
      click button "Bind…" of sheet 1 of window "Directory Utility" of application process "Directory Utility
    <<WAIT LINE HERE FOR NETWORK ADMIN AND AND PASS, THEN USER WILL CLICK OKAY, THEN CONTINUE SCRIPT>>
    <<QUIT ACTIVE DIRECTORY>>
    <<SELF-DESTRUCT>>
    end tell
    It isn't a real command prompt like if you're changing System Preferences or something. It's a specialized prompt specifically for Directory Utility. However, I do need to know how to make AppleScript wait for a password for a standard Password Prompt for adding a certificate to the login keychain through Keychain Access. I've also done pretty much the same thing as above for that script.
    Any tips would be GREATLY appreciated.

    Yeah, I know GUI Scripting is not the best way, but I couldn't find a successful variable system for the following script. The other issue is that I'd prefer to send this by ARD and have ARD ask for a User Name and Password, but I've found there's no way to do that. Then again, I can't send the AppleScript purely remotely either.
    What I mean by self-destruct is simply I only want the Active Directory binding script to run once upon login to the primary admin user and then delete itself so it doesn't get run again. The login certificate script I want to run once on each new user who logs in (so I'll likely be putting it in the "User Template") and then delete itself so it doesn't run the next time they log in. I can't figure out any way to hit those buttons through a shell script.
    Here's the original UNIX shell script: (This is what I'm using temporarily until I figure out a solution that doesn't require my user name and password to be embedded)
    #! /bin/bash
    MACNAME=$(scutil --get ComputerName)
    dsconfigad -add "CORP.DOMAIN.NET" \
    -username USER \
    -password PASS \
    -computer $MACNAME \
    -mobile disable \
    -mobileconfirm disable \
    -localhome enable \
    -useuncpath enable \
    -shell /bin/bash \
    -ou OU=Macs,CN=Computers,DC=corp,DC=DOMAIN,DC=net \
    -force \
    -localpassword "PASSWORD" \
    -groups "GROUPS"
    And here is the Certificate Installation AppleScript
    activate application "Keychain Access"
    tell application "Finder" to open POSIX file "/FolderName/Certificate.crt"
    delay (3)
    tell application "System Events" to tell process "Keychain Access"
      click button "Add" of window "Add Certificates"
      click button "Always Trust" of group 3 of sheet 1 of window "Keychain Access"
    end tell
    Thanks for the help. I really appreciate it. This is a rather new field for me and most of my knowledge comes from Google Searches and about a billion tabs trying to find answers.

  • Popup screen with two check box and a text area for the user to enter value

    hi,
    i have a requirement when a button is clicked a popup screen should appear with two check box and a text box where the user can enter a value.
    is there any function module which has that functionality

    Hello,
    You can create a new screen and select the screen type as <b>model dialog box</b>.This will give you a<b> pop-up screen</b> and you can call this model dialog box screen in the PAI of the screen where the button is present.(At user-command).
    <b>case ok_code.
    when 'BUTTON'.
    call screen 200 starting at 10 10.</b>
    You can design the PBO of this pop-up screen as per your needs.
    Regards,
    Beejal
    **Reward if this helps.

  • How do I set options to programs for my user. ie in .bashrc? (Solved)

    How can I set the following option to make in .bashrc ?
    MAKEOPTS="-j3"
    So the option gets activated each time i open a term/x-term
    Thanks
    Last edited by zann (2013-03-07 03:52:18)

    Sorry im little sleepy
    You know you can set option for make on the command line.
    $ MAKEOPTS='j3' make all
    I want to set that MAKEOPTS in my bashrc file for my user.
    Ive tryed
    in .bashrc
    export -x MAKEOPTS ..
    export -n MAKEOPTS ...
    declare -x MAKEOPTS ...
    Is it clear now what I want?

  • Problems with a certain program for existing users

    Hello,
    We have problems with a third party software application. We have installed this software program on a terminal server (server 2003 32bit) and when we open this software with a existing user account the application crashes with the following entry in the
    eventviewer:
    Application Error 100
    Faulting application ProTime.exe, version 4.1.0.9, faulting module msvbvm60.dll, version 6.0.97.82, fault address 0x000fd0d9.
    For more information, see Help and Support Center at
    http://go.microsoft.com/fwlink/events.asp.
    We have checked the eventlog on the server but the only error that we see is the application error 100 when we open the program. Also we checked the rights on the program's database and folders but that doesn't help either.
    The last thing we did was;
    - Installing the software on a brand new virtual server with server 2003 x86 (no other software installed)
    - Installing the software on a new virtual machine with server 2008 r2 x64 (no other software installed)
    The strange thing is when we change something in the compatibility mode setting for example run as windows xp then we can run the program just fine but when the user logs off and log on again it doesn't work until you change something at the compatibility
    mode setting (doesn't mather which setting)
    When we create a new domain user then the software works properly without any settings changed.
    Any idea what could cause this problem?
    Thanks
    With kind regards,
    Lars

    Hi Jesper,
    Sorry for the late response. We think so, atleast the software company says it is.
    We should not use the compat. mode because the application is not working on server 2003 x86, server 2003 x64, server 2008 r2.
    It is just really strange. Software company has no clue how to fix this problem and they say it is caused by the active directory because when we add a new user then the application starts properly. User accounts created a long time ago are not able to start
    the application.

  • I have signed up for the apple beta software program for public users and when i sign in to the appleseed page i only get an option to enroll my Mac. But what i want is to enroll my iphone for the public releases. How can i go forward with this?

    need to have the option enroll ios on the apple beta software program page

    That's the wrong email message. There's a separate one that was sent out for iOS.

  • Up-to-date program for overseas users?

    Hi
    Does anyone know whether the up-to-date program (free upgrade to Mountain Lion) is application for customers living outside US/Canada?  The terms and conditions on the website says this offer is only valid for US/Canada customers, which I find a little strange.
    I just purchased my mac online and wanted to apply for free upgrade.
    Thanks.

    You probably need to contact Apple directly to get a definite answer.
    My guess is that you simply should use the country on the receipt, but if you bought it with an Apple account or credit card that uses a US address, that could apply as well.
    You do not say where you are stationed, but as far as I know, the deal applies to most countries.
    For the other question in this thread, in Danish both "gift" and "giftstof" can be used.

  • Trouble with an internet mail program for managed user

    Not sure if I am posting this question in the right section.
    I have a new imac, and kids are managed users. I put some parental controls on them I picked and chose with all the various choices.
    They have a login website through their school where they can send and receive emails only with other students and teachers.
    Its not working on their managed accounts. It DOES work under my administrator account, or a "test" user, an unmanaged account. The browser used is Firefox 3.0.4.
    Does anyone have any idea what the problem might be?
    Taffers

    That sounds like a problem with the browser you're using. It may be that the browser must run from within the user's account and not your admin account. Try making a copy of the browser and placing it in the user's Applications folder - /Users/sonsuserfolder/Applications/. If there isn't an Applications folder there then make a new folder and name it Applications. Put the browser copy in that folder. Now log into the account and run the browser from his Applications folder rather than the system's.
    Have you tried using Safari instead of Firefox? Is it possible that the school's system is not intended to be accessed from another network, thus it generates that error message because it will not accept an outside access. Or you may need to find out from the school how to access their network from home.

  • For all users of the newest MBPs - freezing problem

    I spent the whole last week trying to detect the problem of the freezing OS (every N minutes, a freeze for 20-30 sec).
    If you're experiencing the same issue, don't waste your time uninstalling 'suspicious' software like I did… this helps. Really:
    http://forums.macrumors.com/showthread.php?p=8414998&posted=1#post8414998
    Downgrading the EFI 1.7 (preinstalled or installed with Software Update) to EFI 1.6 solves the problem. No more freezing. The update procedure seemed a bit risky to me but well, it worked (you can use an USB stick, I used my external USB hard drive)
    My tech specs: MacBookPro5,4, 2,53 GHz, 4GB RAM, HDD - Hitachi HTS545025B9SA02, OS 10.6.1
    One more thing: in case of other strange problems, try uninstalling Logitech mouse drivers if you've got those. That one solved my coreservicesd crashing problems. I'm waiting for the incoming update of Logitech.

    yes, I did. I spent at least 8 hours searching for a solution here, in the forums and tried everything making sense... The EFI downgrade was the only thing that helped.
    My personal opinion is: Apple should offer the EFI downgrade option to all users in an official way. It looks like my favorite vendor does not want to admit they made a hardware+software mistake (the EFI 1.7 update solves some HDD issues on some new MBPs but causes other problems on other MBPs).
    Message was edited by: Bartek Bargiel

  • Spaces and MS Word for Mac 2008..anyone else having this problem

    Hello,
    I know MS Word for Mac 2008 isn't a Apple Product but is anyone else having the same problem as me and is there a solution?
    I have it set up to be in "spaces 4" and I'll be working on it and suddenly it ends up in space 2, or 1. Really aggravating.
    Sean

    Yes. Exact same problem. Folks at the MS MacBu are aware of it and say that both Apple and MS are working on it. It's still an incredibly annoying problem, though. In fact, it's even worse than you descrine.
    Not only does Word 2008 work with spaces, it makes it impossible to use spaces with other applications. I've tried to leave all Word docxs (and docs) in one space and then put other applications in other spaces. It doesn't work. Word doc(x)s still move around randomly.
    It's one thing for Word 08 not to work with spaces, but to actually interfere with other apps that do (did) work with spaces, that's pretty bad. I have to admit I feel quite foolish for purchasing Microsoft Office 2008 (at considerable expense). I do at least hope both companies are working on a fix.

  • Im having a problem updating my ipad2 its always having a message that my device not elligable for a request field?, Im having a problem updating my ipad2 its always having a message that my device not elligable for a request field?

    Im having a trouble updating my ipad2

    Have you got the latest version of iTunes on your computer ? The This device is not eligible for the requested build message is covered in this article http://support.apple.com/kb/TS3694

  • I have never used my mac for desktop publishing before and am having some problems.  This sounds really dumb, but I can't figure out how to put a border around a text box.  Also, how do you edit the border, i.e. border color, thickness, etc. Help!

    I have never used my mac for desktop publishing before and am running into some real problems.  How do you put a border around a text box?  Can you edit the border - color, thickness, etc.?  Help!

    I think the best solution is to read Pages documentation, go to Help and you have a long list of options. Pages is capable of quite sophisticated things, some features are above Nisus or Mellel, so it is not so simple to summarize things in a few lines.

  • Adobe flash 11.4.402.265 doesn't work for me either. Anyone else having a problem?

    I installed the latest update and once again this version is not working for me either. I again had to go back to 10.3 Is it okay for me to just stay with 10.3 indefinately?

    If neither the 11.4 not working then it is recommended to install 10.3 (see : [https://support.mozilla.org/en-US/kb/flash-113-crashes#w_step-2-install-flash-10-3 Install Flash 10.3]), if you want to test another option to go back to 11.4 and try to [https://support.mozilla.org/en-US/kb/troubleshoot-extensions-themes-to-fix-problems#w_turn-off-hardware-acceleration Turn off hardware acceleration] and "disable the hardware acceleration" in the Flash Player too :
    http://helpx.adobe.com/flash-player/kb/video-playback-issues.html
    http://www.macromedia.com/support/documentation/en/flashplayer/help/help01.html
    also [http://kb.mozillazine.org/Flash#Disabling_Protected_Mode_in_Flash_11.3 Disabling Protected Mode in Flash] (the link is for 11.3, do the same for 11.4), see : "Last resort" in the next link http://forums.adobe.com/thread/1018071?tstart=0
    thank you

Maybe you are looking for

  • IPod became an unreadable disk

    I've been facing a puzzling problem with my 15GB iPod recently. i'm using Mac OS 10.2.8 When i hook up the iPod to the firewire, i get this message: “A disk attempting to mount as Unknown has failed verification or has failed to mount. Please use Dis

  • What's the best settings to Export movie for smaller file sizes?

    Hi, I've been working on some helmet cam footage which was taken with Xvidmpeg4.avi and was advised to convert it to dvavi for editing in PrE, this created a huge file to work with, the original footage was 206mb and the finished edited dvavi file is

  • Trip reimbursement and travel expense deduction

    Hi all, we need detailed info about trips before these trips are setteled (esp. vpfps and vpfpa are of interest). Therefore i tried to submit report rprtec00 with option "export list to memory". if i import information afterwards from database pcl1 n

  • Adobe on ipad and iphone

    How can i see the docs that i have on my adobe on my ipad on the adobe on my iphone?

  • Windows (7) Partition "hidden"

    it's not just hidden.. i can't even set it as startup disk.. there are 2 partitions for windows, the main one (which has about 250 gb capacity) and one for windows files (100 mb aprox.), the last one is the disk0s3 (the big one is disk0s4) but from M