Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 18th, 2012, 06:52 PM
Quadraxis Quadraxis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 Quadraxis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 49 sec
Reputation Power: 0
GPA Program - Theoretical Formatting Question

Hi there whomever is reading this,

I was tasked with making a GPA Program. The program is supposed to be able to calculate Grade Point Average on a weighted scale. It must be able to input user data, calculate the GPA score based on a weighted scale based on ranges of values for each score, and, after doing this 7 times and taking the average of all 7 inputs, output the overall GPA. Here's where I ran into my problem. I was able to make a successful program, but it had exceeded the size requirements. My program had utilized an array along with multiple if statements to determine the un-weighted GPA value, and using some math calculations, output the weighted GPA. The program was roughly 280 lines of code, exceeding the limit of 200. So my question for you is this: How would you format this program so that it could run under the limitation? I'm not asking for somebody to do my homework for me, I'm just asking for how it should run, as in, the basic format I should use. I'm only starting Java, so it would help if your answer would be a simple one.

Thanks for your time,

Raj

Reply With Quote
  #2  
Old October 18th, 2012, 08:23 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,711 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 45 m 48 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Well, start with what you have and see if there's anything that can be removed or compressed. Like maybe you have a few temporary variables that are only used once,
Code:
var = some value;
do something(var);

and could be reduced to the one line
Code:
do something(some value);


I bet you can get more specific answers if we could see the code you have.

Reply With Quote
  #3  
Old October 19th, 2012, 08:49 AM
Quadraxis Quadraxis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 Quadraxis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 49 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
Well, start with what you have and see if there's anything that can be removed or compressed. Like maybe you have a few temporary variables that are only used once,
Code:
var = some value;
do something(var);

and could be reduced to the one line
Code:
do something(some value);


I bet you can get more specific answers if we could see the code you have.


Good Point, here's a sample of the code I used, it pretty much follows this pattern, with an else statement that says "Invalid Input" corresponding to each if. Note: I used an array here.

//Input Area
if(scano1.hasNextLong())
{
int r1 = (int)(scano1.nextLong());
double x1 = (double)(g[r1]);
Scanner scano2 = new Scanner(System.in);
System.out.print("Please enter second class percentage grade for calculation: ");

if(scano2.hasNextLong())
{
int r2 = (int)(scano2.nextLong());
double x2 = (double)(g[r2]);
Scanner scano3 = new Scanner(System.in);
System.out.print("Please enter third class percentage grade for calculation: ");

if(scano3.hasNextLong())

Reply With Quote
  #4  
Old October 19th, 2012, 11:31 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,711 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 45 m 48 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Well you don't need to create a new Scanner every time, there's -6 lines. I'm not sure why you have the x* variables when you already have the values in the g array. And it seems like that array is some big thing mapping all percentages to GPAs? That can surely be eliminated in favor of some math.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > GPA Program - Theoretical Formatting Question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap