Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help with making a grade converter

    Hi,

    First of all, I'm very new to javascript but I do have knowledge of html. My boyfriend has a computer class and I told him I'd help him out as much as I can with his homework. Well, little did I know, I have no idea where to begin. I was able to complete the first question, but I'm now stuck here on the second.

    So below is the question. I have no idea where to even begin. I know it may be too much to as for the whole code, but if anyone can point in a direction of where to start I'd be very thankful. Anything such as what type of code it is, where to look etc.. Thank you!

    "Write a javascript funtion that converts a numerical grade to a letter grade. The write a program that continuously prompts the user for input. (The numerical grade), uses your function to convert the numerical grade to the letter grade and displays the letter grade on the screen until the user no longer wishes to continue. The user will click cancel when he doesn't want to continue.

    You can assume the user will always use an integer but it may be any integer. If the user puts in an invalid numerical grade(such as a number less than 0 or greater than 100) the program should just put: Invalid Input.

    Use this grading scheme:

    85-100 = A
    80-84 = A-
    75-79 = B+
    70-74 = B
    65-69 = B-
    60-64 = C+
    55-59 = C
    50-54 = D
    0-49 = F

    Once again, any help is appreciated! thanks

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    do something like:

    1. prompt the user for an input

    Code:
    var result = prompt('Please enter the grade', ' ');
    2. place the result

    Code:
    if (result <= 49) {
    	alert("Grade F");
    }
    
    if ((result >= 50) && (result <= 54)) {
    	alert("Grade E");
    }
    etc. etc.
    that should do the trick!

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here you go! Hope you don't mind one-liners...
    Code:
    <a href="javascript:var g;while((g=prompt('Enter a numeric grade 0-100'))!=null){g=parseInt(g);if(isNaN(g)||(g<0)||(g>100))alert('Invalid Input');else{var l;if(g>=85)l='A';else if(g>=80)l='A-';else if(g>=75)l='B+';else if(g>=70)l='B';else if(g>=65)l='B-';else if(g>=60)l='C+';else if(g>=55)l='C';else if(g>=50)l='D';else l='F';alert('Grade: '+g+' = '+l+'.');}}">Click here to convert grades</a>

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,081
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by VortexCortex View Post
    Here you go! Hope you don't mind one-liners...
    Code:
    <a href="javascript:var g;while((g=prompt('Enter a numeric grade 0-100'))!=null){g=parseInt(g);if(isNaN(g)||(g<0)||(g>100))alert('Invalid Input');else{var l;if(g>=85)l='A';else if(g>=80)l='A-';else if(g>=75)l='B+';else if(g>=70)l='B';else if(g>=65)l='B-';else if(g>=60)l='C+';else if(g>=55)l='C';else if(g>=50)l='D';else l='F';alert('Grade: '+g+' = '+l+'.');}}">Click here to convert grades</a>
    The class teacher, being on the dim side, will almost certainly not realise that this "one liner" is not the student's own work.

  • #5
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! His teacher didn't seem very smart... When I looked over the class notes, there was nothing about what I needed to know which was pretty confusing. But thanks!

    Woops, what I meant to add was that his teacher doesn't seem to know very much about his topic and I'm actually pretty sure he could get away with it... or maybe not. lol
    Last edited by cari44; 11-01-2006 at 04:50 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •