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 8014455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:56:29+00:00 2026-06-04T19:56:29+00:00

First off, I’m a beginner at this… so if what I’m doing is pretty

  • 0

First off, I’m a beginner at this… so if what I’m doing is pretty simple to fix (or do in general), I apologize 🙂

I’m trying to take user inputs (laps [int], fuel used [double], and laps of a feature [int]) to create a simple fuel calculator for racers. However, I’m having trouble getting the variables to recognize. I keep getting errors about I’m unable to use one function in a certain class and things like that. I’ve got the XML fields assigned to only take those types of numbers, so now I’m working strictly in the java.

I had the thing working in the java compiler, but taking it to Android is a whole other process I’m learning.

After calculating from the user inputs, I want the assigned textView to change to the proper answers. I think that part is ok, but getting the values to mathematically-viable values is where I’m running into a problem.

I’ve attached the entire code here (pardon the redundancy with comments, keeps me from looking back and forth for the formula haha). Any help you can provide would be appreciated! I’ll do my best to learn from it for the other math-related activities in this app.


    package com.tomcat.carolina.learning;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.RadioGroup;
    import android.widget.TextView;




    //double pracLaps, fuelUsed, featureLaps, textLPGValue, textFuelNeededValue;


    public class Fuelsimple extends Activity implements OnClickListener{

EditText fuelUsed, pracLaps, featureLaps;
TextView textLPGValue, textFuelNeededValue;
//efficiency = (pracLaps / fuelUsed);
//fuelNeeded = (featureLaps / efficiency);

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fuelsimple);

pracLaps = (EditText) findViewById(R.id.pracLaps);
fuelUsed = (EditText) findViewById(R.id.fuelUsed);
featureLaps = (EditText) findViewById(R.id.featureLaps);
Button gen = (Button) findViewById(R.id.submit);
textLPGValue = (TextView) findViewById(R.id.textLPGvalue);
textFuelNeededValue = (TextView) findViewById(R.id.textFuelNeededValue);








gen.setOnClickListener(new View.OnClickListener() {     
    public void onClick(View v) {
        // TODO Auto-generated method stub



        textLPGValue.setText(getNextDecimal(pracLaps / fuelUsed));
        textFuelNeededValue.setText(getNextDecimal(featureLaps/(pracLaps / fuelUsed)));
    };
    });
  • 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-06-04T19:56:30+00:00Added an answer on June 4, 2026 at 7:56 pm

    I hope this is what you are looking for:

    pracLaps = (EditText) findViewById(R.id.pracLaps);
    fuelUsed = (EditText) findViewById(R.id.fuelUsed);
    featureLaps = (EditText) findViewById(R.id.featureLaps);
    
    pracLapsVar = Double.parseDouble(pracLaps.getText().toString());
    fuelUserVar = Double.parseDouble(fuelUsed.getText().toString());
    featureLapsVar = Double.parseDouble(featureLaps.getText().toString());
    
    
    efficiency = (pracLapsVar / fuelUsedVar);
    fuelNeeded = (featureLapsVar / efficiency);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off I apologize if there is another post out there that answers this,
First off, let me apologize if I'm writing this in the wrong place. I
First off, I'm sure this is a simple question. I'm just getting started with
First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS
First off, I apologize for my inaccurate vocabulary. I am an absolute ground-zero beginner.
First off the html row looks like this: <tr class=evenColor> blahblah TheTextIneed blahblah and
First off, I'm aware this is a bad practice and I have answered many
First off, thank you to everyone on this site...it's been INCREDIBLY helpful in getting
First off, a big thanks to the people behind the new boost::geometry library! This
First off, I want to apologize beforehand, as I know there is a lot

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.