Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Help With C3 Programming Homework Problem


  • Please log in to reply
5 replies to this topic

#1 debbiew

debbiew

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:08:33 AM

Posted 17 September 2008 - 02:52 PM

Hello everyone, my name is Debbie and I am a student at Devry University in NJ. I've been a hairdresser for 10 years and changing careers. Anyhow, I hope someone could help me with a problem I have to code:

Create a program which calculates students final grades. The student will have 3 quiz scores, 5 lab scores, 5 homework scores and a final exam grade. All assignments are worth 100 points each. Get all the scores into the program and total their points received, and send their points received to a method called CalculateGrade(). This method will take the number of points the sudent received and divide it by the total number of points possible. It will then determine the student's final letter grade by using the 90-100, 80-89, 70-79, 60-69 and below 60 is failing. The CalculateGrade() method will output their total points received, their average, and their final letter grade.

I am ashamed I have been at this program for hrs and cannot figure out how to do it.

any help is greatly appreciated, thanks

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:06:33 AM

Posted 17 September 2008 - 03:32 PM

We won't do your homework for you, but we are happy to help 'nudge' you along once we see what you do have. What have you got so far?

#3 debbiew

debbiew
  • Topic Starter

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:08:33 AM

Posted 17 September 2008 - 03:53 PM

OK, sounds good. Here is what I have so far:

public static void Main()
{
string name;
int q1, q2, q3, l1, l2, l3, l4, l5, hw1, hw2, hw3, hw4, hw5, final;
grade = GetGrade();
total = CalculateGrade (q1, q2, q3, l1, l2, l3, l4, l5, hw1, hw2, hw3, hw4, hw5, final);
lettergrade = GetLetterGrade();
}

Console.WriteLine ( "enter student's name ");
return (Console.ReadLine());

Public static int GetGrade()
{
return int.Parse (Console.ReadLine());
}

public static int CalculateGrade(q1, q2, q3, l1, l2, l3, l4, l5, hw1, hw2, hw3, hw4, hw5, final)
{
Console.WriteLine ("the total grade is ");
return int.Parse (console.ReadLine());


This is as far as I got because I couldnt figure out the compiler errors. It didnt like the commas, and told me that total wasnt in context, or calculate grade, etc. But my teacher had built a similar program using the similar way declaring the variables. Im just so confused.

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:06:33 AM

Posted 17 September 2008 - 04:41 PM

Your "CalculateGrade" method is the problem there. You are passing a bunch of parameters to your method, but you are not designating the type of parameters in the method. In other words, it should be like this (for example):
int i=1;
myMethod(i);

So all I am doing is declaring an int with a value of one, and passing that value to my method. So now in my method, I must do this:

myMethod (int i){
....do something
}

Do you see the problem? Fix that, and see where it gets you.

#5 debbiew

debbiew
  • Topic Starter

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:08:33 AM

Posted 17 September 2008 - 05:32 PM

ok, this is what I have, I keep trying to start program as I go along as that is what I was told to do, well the console window comes up, no errors, but just says press any key to continue, but at this point shouldnt this program be asking for a name?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
public static void Main()
{
string name;
int i = qz1, qz2, qz3, lb1, lb2, lb3, lb4, lb5, hw1, hw2, hw3, hw4, hw5, final;
grade = CalculateGrade(i);
avg = GetAverage(i);
letter = DisplayLetter(i);
points received
Console.WriteLine("enter Student's name ");
name = Console.ReadLine();


}
public static int CalculateGrade()
{
Console.WriteLine("enter he total number of points scored ");
return int.Parse(Console.ReadLine());
}
public static int GetAverage()
{
return (CalculateGrade / 14);
}



}
}
}

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:06:33 AM

Posted 17 September 2008 - 05:42 PM

No, that wasn't what I meant to do. I was trying to show you an example of what you should do, not what you should actually do. Passing parameters to functions is a bit of a mind-blow at first, but once you get it, it is gravy. Let me try again, but first, lets try bit by bit. YOu have abunch of things going on here, so this may take a bit to get you on tack here.

First of all, that program should not even compile. You have a line in there that is not even valid programming syntax. Actually, you have a bunch of stuff that is not valid syntax. So for now, get rid of everything else,and just start with getting the student's name. Show me just that code. We will make that work first.

Incidentally, what IDE are you using?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users