GPA calculator don't work!!

Put your problem here if it does not fit any of the other categories.

GPA calculator don't work!!

Postby AndroidGoal » Thu Oct 29, 2009 3:14 am

I have attached my project file as I am very new to Android Platform but familiar to Java....My GPA calculator doesn't work. Can you guys help me? I want to calculate GPA based on lettergrade and numerical credits and for this I have assigned numerical values to lettergrade and trying to retrieve them but I fail always.....please find the .7z project file attached.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package gpa.android;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.os.Bundle;
  8.  
  9. import android.view.View;
  10.  
  11. import android.widget.Button;
  12.  
  13. import android.widget.EditText;
  14.  
  15. import android.widget.TextView;
  16.  
  17.  
  18.  
  19. public class InputGrade extends Activity {
  20.  
  21.        
  22.  
  23.         char grade;
  24.  
  25.         boolean result;
  26.  
  27.         int FinalGrade;
  28.  
  29.         double credit2;
  30.  
  31.         double points;
  32.  
  33.                 Double point;
  34.  
  35.         double credit;
  36.  
  37.        
  38.  
  39.         double GPA;
  40.  
  41.        
  42.  
  43.         private EditText student;
  44.  
  45.         EditText lettergrade;
  46.  
  47.         EditText credits;
  48.  
  49.         EditText GPA1;
  50.  
  51.         TextView operator ;
  52.  
  53.         Button calculate;
  54.  
  55.        
  56.  
  57.         public void onCreate(Bundle savedInstanceState) {
  58.  
  59.         super.onCreate(savedInstanceState);
  60.  
  61.         setContentView(R.layout.main);
  62.  
  63.         control();
  64.  
  65.         }
  66.  
  67.                 public void control(){
  68.  
  69.         student = (EditText)findViewById(R.id.FirstName);
  70.  
  71.         lettergrade = (EditText)findViewById(R.id.Grade);
  72.  
  73.         credits = (EditText)findViewById(R.id.Credits);
  74.  
  75.         GPA1 = (EditText)findViewById(R.id.EditText01);
  76.  
  77.        
  78.  
  79.         calculate = (Button)findViewById(R.id.Button01);
  80.  
  81.        
  82.  
  83.         calculate.setOnClickListener(new View.OnClickListener(){
  84.  
  85.  
  86.  
  87.                         public void onClick(View v) {
  88.  
  89.                                 calculate();
  90.  
  91.                         }
  92.  
  93.                
  94.  
  95.         });
  96.  
  97.                 }
  98.  
  99.                
  100.  
  101.                 public double getGrade(){
  102.  
  103.                        
  104.  
  105.                        
  106.  
  107.                        
  108.  
  109.                         if(point == 'A')
  110.  
  111.                                 credit2 = 4.0;
  112.  
  113.                         else if(point == 'B')
  114.  
  115.                                 credit2 = 3.0;
  116.  
  117.                         else if(point == 'C')
  118.  
  119.                                 credit2 = 2.0;
  120.  
  121.                         else if(point == 'D')
  122.  
  123.                                 credit2 = 1.7;
  124.  
  125.                         else if(point == 'F')
  126.  
  127.                                 credit2 = 1.0;
  128.  
  129.                         else
  130.  
  131.                                 result = true;
  132.  
  133.                        
  134.  
  135.                         return credit2;
  136.  
  137.                 }
  138.  
  139.        
  140.  
  141.                 private void calculate(){
  142.  
  143.                 //points1=Double.parseDouble(lettergrade.getText().toString());
  144.  
  145.                
  146.  
  147.                 //points = getGrade(grade)*FinalGrade;
  148.  
  149.                         point = Double.parseDouble(lettergrade.getText().toString());
  150.  
  151.                 credit = Double.parseDouble(credits.getText().toString());
  152.  
  153.                
  154.  
  155.                
  156.  
  157.                 GPA = credit2 / credit;
  158.  
  159.                 GPA1.setText(Double.toString((GPA)));
  160.  
  161.                 }
  162.  
  163.         }
  164.  
  165.  
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
AndroidGoal
Freshman
Freshman
 
Posts: 4
Joined: Thu Oct 29, 2009 2:54 am

Top

MY CALCULATOR DOESN'T WORK

Postby AndroidGoal » Tue Nov 03, 2009 4:23 am

Can any one please help me with this code. However I have another form of calculator running but I wanna find out my errors in this program to learn better. please provide your feedback.
AndroidGoal
Freshman
Freshman
 
Posts: 4
Joined: Thu Oct 29, 2009 2:54 am

Please help me with this..............coding problem

Postby AndroidGoal » Tue Nov 03, 2009 7:22 am

I am not new to Java but new to android and I wanna learn it please can you give guys some assistance...
I have attached the file can someone please point out my mistake I am trying to apply my basic java logic but this doesn't seem to work.
Attachments
AndroidGPA.zip
(30.9 KiB) Downloaded 45 times
AndroidGoal
Freshman
Freshman
 
Posts: 4
Joined: Thu Oct 29, 2009 2:54 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: TurnitinBot [Bot] and 19 guests