Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:08:57+00:00 2026-05-29T05:08:57+00:00

I am trying to make this app that calculates your grade average (based on

  • 0

I am trying to make this app that calculates your grade average (based on the Swedish grade system) and I have made the graphical layout and written the java code in eclipse that I think is right, but when I try to launch it in the emulator it won´t work. The app starts, but its only a black screen. This is my first app and my first programming project so I don´t really know what I have done wrong.

It is supposed to be three edittexts where you put the amount of points you have with a cerrtain grade (we have three grades) and then it should multiply the points with the 10, 15 or 20 depending on what grade it is and then divide by the total amount of points. I dont know if that makes sense, but the maxmimum grade is supposed to be 20 (all mvgs). I made a similar app in C# and it works, but Im guessing things are done a little different when it comes to android and java.

package com.dlol.gradeaverage;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class GradeaverageActivity extends Activity {

EditText editText1, editText2, editText3;
String gtext, vgtext, mvgtext, str;
Double gpoäng, vgpoäng, mvgpoäng;
Double gvärde, vgvärde, mvgvärde;
Double allapoäng, allavärde;
Double snittbetyg;
Button button1;



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);    

 editText1 = (EditText)findViewById(R.id.editText1); 
 editText2 = (EditText)findViewById(R.id.editText2); 
 editText3 = (EditText)findViewById(R.id.editText3); 

 gtext = editText1.getText().toString();
 vgtext = editText2.getText().toString();
 mvgtext = editText3.getText().toString();

 gpoäng = Double.parseDouble(gtext);
 vgpoäng = Double.parseDouble(vgtext);
 mvgpoäng = Double.parseDouble(mvgtext);

 gvärde = gpoäng*10;
 vgvärde = vgpoäng*15;
 mvgvärde = mvgpoäng*20;

 allapoäng = (gpoäng + vgpoäng + mvgpoäng);
 allavärde = (gvärde + vgvärde + mvgvärde);

 snittbetyg = (allavärde / allapoäng);
 str = "Ditt snitt är " + snittbetyg;

 button1 = (Button)findViewById(R.id.button1);  

 button1.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {
         Toast.makeText(getBaseContext(), str,
                 Toast.LENGTH_SHORT).show();
     }
});
}}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/info_text_G" 
    android:textSize="16sp">
</TextView>

<EditText 
    android:id="@+id/editText1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="text">        
</EditText>/

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/info_text_VG" 
    android:textSize="16sp" />

 <EditText 
    android:id="@+id/editText2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="text">        
</EditText>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/info_text_MVG" 
    android:textSize="16sp">        
</TextView>

<EditText 
    android:id="@+id/editText3"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="text">        
</EditText>

<Button
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/Button" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, GradeaverageActivity!</string>
<string name="app_name">Gradeaverage</string>
<string name="info_text_G">Skriv in antal G-poäng</string>
<string name="info_text_VG">Skriv in antal VG-poäng</string>
<string name="info_text_MVG">Skriv in antal MVG-poäng</string>
<string name="Button">Räkna ut snitt!</string>
</resources>

02-05 17:07:06.184: D/AndroidRuntime(1230): Shutting down VM
02-05 17:07:06.184: W/dalvikvm(1230): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
02-05 17:07:06.184: E/AndroidRuntime(1230): Uncaught handler: thread main exiting due to uncaught exception
02-05 17:07:06.194: E/AndroidRuntime(1230): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dlol.gradeaverage/com.dlol.gradeaverage.GradeaverageActivity}: java.lang.NumberFormatException:
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.os.Handler.dispatchMessage(Handler.java:99)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.os.Looper.loop(Looper.java:123)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.app.ActivityThread.main(ActivityThread.java:3948)
02-05 17:07:06.194: E/AndroidRuntime(1230): at java.lang.reflect.Method.invokeNative(Native Method)
02-05 17:07:06.194: E/AndroidRuntime(1230): at java.lang.reflect.Method.invoke(Method.java:521)
02-05 17:07:06.194: E/AndroidRuntime(1230): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
02-05 17:07:06.194: E/AndroidRuntime(1230): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
02-05 17:07:06.194: E/AndroidRuntime(1230): at dalvik.system.NativeStart.main(Native Method)
02-05 17:07:06.194: E/AndroidRuntime(1230): Caused by: java.lang.NumberFormatException:
02-05 17:07:06.194: E/AndroidRuntime(1230): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:258)
02-05 17:07:06.194: E/AndroidRuntime(1230): at java.lang.Double.parseDouble(Double.java:323)
02-05 17:07:06.194: E/AndroidRuntime(1230): at com.dlol.gradeaverage.GradeaverageActivity.onCreate(GradeaverageActivity.java:37)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
02-05 17:07:06.194: E/AndroidRuntime(1230): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
02-05 17:07:06.194: E/AndroidRuntime(1230): … 11 more
02-05 17:07:06.225: I/dalvikvm(1230): threadid=7: reacting to signal 3
02-05 17:07:06.244: I/dalvikvm(1230): Wrote stack trace to ‘/data/anr/traces.txt’
02-05 17:07:06.344: I/jdwp(1230): received file descriptor 24 from ADB
02-05 17:07:06.354: W/System.err(1230): Can’t dispatch DDM chunk 46454154: no handler defined
02-05 17:07:06.354: W/System.err(1230): Can’t dispatch DDM chunk 4d505251: no handler defined

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:08:58+00:00Added an answer on May 29, 2026 at 5:08 am

    You get a NumberFormatException because when you create the Activity(onCreate() method) you already try to parse the text from the EditText(you have emty text "" and trying to parse it to Double will trow an Exception) although you didn’t entered any numbers yet. You have to move the code for calculating the grades on the button’s OnCLickListener like this:

       @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);    
    
         editText1 = (EditText)findViewById(R.id.editText1); 
         editText2 = (EditText)findViewById(R.id.editText2); 
         editText3 = (EditText)findViewById(R.id.editText3); 
    
         button1 = (Button)findViewById(R.id.button1);  
    
         button1.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
        gtext = editText1.getText().toString();
         vgtext = editText2.getText().toString();
         mvgtext = editText3.getText().toString();
    
         gpoäng = Double.parseDouble(gtext);
         vgpoäng = Double.parseDouble(vgtext);
         mvgpoäng = Double.parseDouble(mvgtext);
    
         gvärde = gpoäng*10;
         vgvärde = vgpoäng*15;
         mvgvärde = mvgpoäng*20;
    
         allapoäng = (gpoäng + vgpoäng + mvgpoäng);
         allavärde = (gvärde + vgvärde + mvgvärde);
    
         snittbetyg = (allavärde / allapoäng);
         str = "Ditt snitt är " + snittbetyg;
                 Toast.makeText(getBaseContext(), str,
                         Toast.LENGTH_SHORT).show();
             }
        });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to make this to be a little jQuery plugin that
This one is killing me. I'm trying to make a simple console app that
I'm trying to make an app that will respond to your command when inserted.
I am trying to make an app that can shutdown/reboot your phone at the
I am trying to make an app that will send your gps location to
I am trying to make this landscape only iphone app. I only use this
im trying to make Categories and Subcategories, im checking this models but i have
I'm trying to make an app that handles orientation/rotation similarly to the way the
I'm trying to make an app that links to Google streetview using latitude/longitude coordinates,
I am trying to make a simple app that read from a midi port

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.