Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Visual Basic Coding Help  (Read 3944 times)

toradrow777

  • Bay Watcher
    • View Profile
Visual Basic Coding Help
« on: September 13, 2013, 06:13:43 pm »

I know I already asked this, but since that thread's pretty much dead I decided to start another.

I'm having trouble here. I know what I want to do, but I have no idea how to even start this.

I have three test scores, five lab scores, four quiz scores, and a final exam score. Each category makes up a certain percentage of a student's total score (the four percentages are set by the user). I need to code my work in order to not only add up the scores in each category and multiply them by the relevant percentage, I need to also to get the average of the four resulting scores (which would give me the final average). I also need a letter grade based on a ten-point grading scale (90-100 is an A, 80-89.99 is a B, etc.).

The equation, basically, is something like this:  Test Score Percentage(Test Score 1 + Test Score 2 + Test Score 3) + Lab Score Percentage(Lab Score 1 + Lab Score 2 + Lab Score 3 + Lab Score 4 + Lab Score 5) + Quiz Score Percentage(Quiz Score 1 + Quiz Score 2 + Quiz Score 3 + Quiz Score 4) + Final Exam Percentage(Final Exam Score)

How do I do this? I need this by the end of TODAY.

Also, I need a reminder, which options do I need on, Explicit, Strict, and/or Infer?
« Last Edit: September 13, 2013, 06:20:14 pm by toradrow777 »
Logged

freeformschooler

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #1 on: September 13, 2013, 06:18:28 pm »

Um... what? The thread was only one day old. Bump it, don't clutter. People regularly resurrect 1+ month old threads here :P

Also, it would really help if you provided code you've already done. LA stands for Life Advice, not Lazy Advice.

If you don't have any code, you might be fucked. Welcome to school.
« Last Edit: September 13, 2013, 06:20:22 pm by freeformschooler »
Logged

toradrow777

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #2 on: September 13, 2013, 06:23:06 pm »

Um... what? The thread was only one day old. Bump it, don't clutter. People regularly resurrect 1+ month old threads here :P

Also, it would really help if you provided code you've already done. LA stands for Life Advice, not Lazy Advice.

If you don't have any code, you might be fucked. Welcome to school.

Maybe you didn't understand the part where I said I had no idea how to start it.  It's been several months since my last Visual Basic lesson, so sue me if I forgotten most of it!  I just need help with this and the rest of the class should be simpler.

Also, I'm using Visual Basic 2010 Express.
Logged

freeformschooler

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #3 on: September 13, 2013, 06:25:06 pm »

Maybe you didn't understand the part where I said I had no idea how to start it.  It's been several months since my last Visual Basic lesson, so sue me if I forgotten most of it!  I just need help with this and the rest of the class should be simpler.

Also, I'm using Visual Basic 2010 Express.

You're not going to get a lot of help if you act like an asshole the people trying to help you.

Here's a starting question: do you have the scores you need to use for the assignment or do you need the user to input them first? If the former, we can blow through this pretty fast. I'm going to err on the side of your instructor gave them to you based on your post, but I just want to confirm.
Logged

toradrow777

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #4 on: September 13, 2013, 06:25:56 pm »

No, it's the latter, same for the percentages.

Also, sorry, but I'm a bit stress out here.
« Last Edit: September 13, 2013, 06:27:37 pm by toradrow777 »
Logged

toradrow777

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #5 on: September 13, 2013, 06:47:56 pm »

Bump
Logged

freeformschooler

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #6 on: September 13, 2013, 06:58:41 pm »

Well, I've never coded in VB in my entire life, but here goes.

Make a variable for each test score, each test average and the percentages for each section as given by the user.

Code: [Select]
Dim testpercent, labpercent, quizpercent, finalpercent As Decimal
Dim test1, test2, test3, testaverage, lab1, lab2, lab3, lab4, lab5, labaverage, quiz1, quiz2, quiz3, quiz4, quiz4, finalexam, classaverage As Integer

To make sure user input works correctly, first ask the user what the section percentages are supposed to be. I'm not sure if you're supposed to have them input the percent or the decimal, so I'm gonna go with percent.

Code: [Select]
Console.Write("What percent of your grade is your test average? (0 to 100 ")
testpercent = Decimal.Parse(Console.ReadLine())/100
Console.Write("What percent of your grade is your lab average? (0 to 100) ")
labpercent = Decimal.Parse(Console.ReadLine())/100
Console.Write("What percent of your grade is your quiz average? (0 to 100) ")
quizpercent = Decimal.Parse(Console.ReadLine())/100
Console.Write("What percent of your grade is your final exam? (0 to 100) ")
finalpercent = Decimal.Parse(Console.ReadLine())/100

(the /100 turns it into decimal form, like 40 to 0.4)

Now set the all the test/quiz/lab variables to whatever they're supposed to be equal to and set the testaverage to their average.

Code: [Select]
Console.Write("What is your first test grade?")
test1 = CInt(Console.ReadLine())
Console.Write("What is your second test grade?")
test2 = CInt(Console.ReadLine())
Console.Write("What is your third test grade?")
test3 = CInt(Console.ReadLine())
testaverage = ((test1,test2,test3)/3 ) * testpercent

This SHOULD set your testaverage to the portion of your final score it's equal to. If your test average is 90 and the user entered 35 for testpercent, testaverage will become 90*0.35 or 31.5

Repeat this for the quizzes, labs, their averages, and finally the exam. For the final exam, you obviously don't have to average anything: just multiply finalexam by finalpercent.

Finally, to get user's score in the class once all of that has been done, you can just sum the portions:

Quote
classaverage = testaverage + quizaverage + labaverage + finalexam

Lastly, for the A-B-C etc thing, you can just use an if statement:

Quote
If (classaverage>=90) Then
   Console.WriteLine("Your score in the class is: {0}. You made an A in the class!",classaverage)
ElseIf (classaverage>=80) And (classaverage<90) Then
   Console.WriteLine("Your score in the class is: {0}. You made a B in the class!",classaverage)
ElseIf (classaverage>=70) And (classaverage<80) Then
   Console.WriteLine("Your score in the class is: {0}. You made a C in the class!",classaverage)
ElseIf (classaverage>=60) And (classaverage<70) Then
   Console.WriteLine("Your score in the class is: {0}. You made a D in the class!",classaverage)
Else
   Console.WriteLine("Your score in the class is: {0}. You made an F in the class!",classaverage)
End If

Again, I've never used vb.net in my life, so this is all guesswork from googling. It may not work, and even if it does, it's guaranteed poor code. Still, if it does work, that's awesome, and if you get errors, let me know. Good luck.
« Last Edit: September 13, 2013, 07:06:44 pm by freeformschooler »
Logged

toradrow777

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #7 on: September 13, 2013, 07:00:35 pm »

No offense, but that is SO not Visual Basic.
« Last Edit: September 13, 2013, 07:02:39 pm by toradrow777 »
Logged

freeformschooler

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #10 on: September 13, 2013, 07:05:04 pm »

Note: I realized there was a logical error just a moment ago. Preeeetty sure CInt(sReadLine) would have just spat out that first input over and over, so I changed all instances to CInt(Console.ReadLine()). Still not sure it'll work, but there you go.

CInt stands for Convert Integer http://msdn.microsoft.com/en-us/library/s2dy91zy.aspx
Logged

timotheus

  • Bay Watcher
  • New to Dwarf Fortress.. Long time ASCII gamer..
    • View Profile
    • Home
Re: Visual Basic Coding Help
« Reply #11 on: September 13, 2013, 07:10:08 pm »


Maybe you didn't understand the part where I said I had no idea how to start it.  It's been several months since my last Visual Basic lesson, so sue me if I forgotten most of it!  I just need help with this and the rest of the class should be simpler.

Also, I'm using Visual Basic 2010 Express.

I can guarantee you a class on programming won't get simpler.

Can you look at your previous VB lesson and homework to help job your memory?
Logged
twitter: @timotheus
email: tim@hithlonde.com
xmpp: tim@hithlonde.com

freeformschooler

  • Bay Watcher
    • View Profile
Re: Visual Basic Coding Help
« Reply #12 on: September 14, 2013, 09:14:04 am »

How did it go? Were you able to implement some of that or come up with anything?
Logged