Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: beginner programmer trouble

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default beginner programmer trouble

    I am a beginning level programmer taking an intro programming class and im still having trouble. These are 2 assignments due monday the 5th of december. if you could either complete them and explain what you did wih comments or talk me through it, either would be great. I also am going to post another one thats for our exam. Just for more information though, I am using Textpad for my java code.


    This assignment consists of two programs, each worth 25 points, for a total of 50 points. For each exercise, make sure you show decimal numbers to the hundredths place.
    Program 7.1
    Write a program that accepts ten student grades. Store the values into an array. Display the following results:
    •The numeric value of each grade
    •The letter grade equivalent (use the class syllabus to see how to derive the letter grade from the number)
    •The highest grade
    •The lowest grade
    •The average grade
    When you present the information, be sure to prefix it with text that describes what the user is seeing. For example, when showing the average, don't just put "85" but put "Average: 85".

    Follow the steps below: 1.Create a Java program, naming the file and the class DisplayGrades.
    2.Put your name, date, program number and title at the top of your program listing as a comment.
    3.Write in the pseudocode for the program as comments before you write the real code.

    4.Meet the requirements stated above.
    5.Display a "Press any key to exit..." and wait for the user to press a key. The program will then end.
    6.Run the program and capture the output. Paste the sample output in as a comment at the bottom of your code listing.

    --------------------------------------------------------------------------------

    Program 7.2

    Write a program that asks the user to enter a value indicating the number of candidates running for an election. Then, for each candidate, allow the user to enter the last name and votes received for the candidate. If the last name is missing or the votes are less than zero, ask the question again until the user enters the correct response. When all the data has been entered, display a table showing the candidate name, votes received, and percent of total votes. A sample output is:


    Follow the steps below: 1.Create a Java program, naming the file and the class Candidates.
    2.Put your name, date, program number and title at the top of your program listing as a comment.
    3.Write in the pseudocode for the program as comments before you write the real code.

    4.Meet the requirements stated above, making sure you store the names and votes received into arrays.
    5.Display a "Press any key to exit..." and wait for the user to press a key. The program will then end.
    6.Run the program and capture the output. Paste the sample output in as a comment at the bottom of your code listing.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: beginner programmer trouble

    You'll get better help if you show that you have put some effort into your assignment.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: beginner programmer trouble

    /*
    Author: Scott Buist
    Date: December 5, 2011
    Title: DisplayGrades
    Prog: 7.1
    Instr: Tim Koets
    */
    import java.util.Scanner;
    public class DisplayGrades
    {
    public static void main(String[] args)
    {
    Scanner input = new Scanner(System.in);
    int count;

    // build an array of the size the user wants
    int[] grades = new int[10];


    // fill the array with data
    for ( count = 0 ; count < 10 ; count++ )
    {
    int grade;
    do
    {
    System.out.print("Enter grade " + (count+1) + ": ");
    grade = input.nextInt();
    if ( grade > 100 )
    System.out.print("Invalid grade. Try again: ");
    else
    grades[count] = grade;
    }while (grade > 100);
    }

    int avg;
    int sum = 0;

    for ( count = 0 ; count < grades.length ; count++ )
    {
    sum = sum + grades[count];
    }

    avg = sum / grades.length;
    System.out.println("The average is " + avg);

    // find the highest grade
    int max = grades[0];
    for ( count = 1 ; count < grades.length ; count++ )
    {
    if ( grades[count] > max )
    max = grades[count];
    }

    System.out.println("The high is " + max);

    // find the highest grade
    int min = grades[0];
    for ( count = 1 ; count < grades.length ; count++ )
    {
    if ( grades[count] < min )
    min = grades[count];
    }

    System.out.println("The low is " + min);
    }
    }

    /* Output:
    Enter grade 1: 56
    Enter grade 2: 90
    Enter grade 3: 76
    Enter grade 4: 89
    Enter grade 5: 100
    Enter grade 6: 0
    Enter grade 7: 29
    Enter grade 8: 76
    Enter grade 9: 87
    Enter grade 10: 95
    The average is 69
    The high is 100
    The low is 0
    Press any key to continue . . .
    */


    That is what i have so far for the first one i just cant incorporate the letter grade part of the assignment

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: beginner programmer trouble

    Can you show what the output of the program is supposed to be?

    i just cant incorporate the letter grade part
    You could use a chain of if/else if statements to chose the letter grade for each range of scores tested for in the if statements.

  5. #5
    Junior Member
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: beginner programmer trouble

    where would i incorporate it though, i tried putting it in there and it made the code act all weird where the letter grades would appear at random times

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: beginner programmer trouble

    i tried putting it in there
    What did you put where? There are lots of things you can put in the wrong places. You will need to show exactly what you did and what happened.

    Write a single method that takes the numeric grade value and returns the letter grade.
    Write a simple program to test it. Call it with a hard coded value and print out what it returns.
    When you get that to work you can copy it into your bigger program. You would call it like this:
    String letterGrade = getLetterGrade(90);
    then print out the value of letterGrade to see if its right.
    Then change the 90 to 78 and do it again. Continue testing until you are sure the getLetterGrade() method is working properly can then copy it to the big program.

Similar Threads

  1. Replies: 7
    Last Post: August 17th, 2013, 07:55 PM
  2. I need a Java programmer in the UK
    By MikeJH in forum The Cafe
    Replies: 1
    Last Post: June 13th, 2011, 06:37 AM
  3. Beginner java programmer!
    By chrisivey1980 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: April 23rd, 2011, 03:06 AM
  4. Beginner programmer... no idea how to implement this properly
    By rkrajnov in forum Java Theory & Questions
    Replies: 1
    Last Post: January 31st, 2011, 08:02 AM
  5. Not a programmer, interested though
    By abigbluewhale in forum Java Theory & Questions
    Replies: 3
    Last Post: August 27th, 2009, 05:27 AM