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

  • Home
  • SEARCH
  • 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 8095945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:18:24+00:00 2026-06-05T21:18:24+00:00

I am developing a small app while learning Android. The app is basically making

  • 0

I am developing a small app while learning Android.

The app is basically making a series of simple math calculations. A button is calling a function where the calculations take place. Everything was working fine, until I inserted an if/else construct.

Inside this construct, I am using variables created before, making calculation and setting other variables with this

if (TS>Ex) {
    Double AE = 0.00;
} else {
    Double AE = (Ex-TS);
};

Double TBTAT = (TS-Ex);
Double Exx = 2864.17;   
if (TBTAT>Exx) {
    Double TAT = (Exx*0.2);
} else {
    Double TAT = (TBTAT*0.2);
};

I have two of these if/else structures.

Then everything is collected and sent to a Text

IT_ResultTXT.setText(Double.toString(AE+TAT+TAF));

In normal conditions, AE, TAT, TAF turn out to “cannot be resolved to a variable” in this last line of the code, but if I declare them at the beginning of the function, I have an error of duplicated variables.

I suppose is a very stupid basic Java programming error, but I cannot find a solution to this.

  • 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-05T21:18:25+00:00Added an answer on June 5, 2026 at 9:18 pm

    You have to declare at the beginning (or somewhere else in enclosing scope), only once:

    Double AE;
    
    if (TS > Ex) {
        AE = 0.00;
    } else {
        AE = (Ex - TS);
    };
    
    Double TBTAT = (TS - Ex);
    Double Exx = 2864.17;    
    
    Double TAT;
    
    if (TBTAT > Exx) {
        TAT = (Exx * 0.2);
    } else {
        TAT = (TBTAT * 0.2);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in the middle of developing a small app for Android using the Android
I am developing a small app in which I want a background service to
I am developing a small app for a Motorola 9090-G using .net compact framework
I am looking into developing a small app to run on a blackberry which
I'm developing small FTP upload app. for mac (10.6 if it matters) Have problem
So I have been developing a small ASP.NET web app in C# for my
I'm developing a small app designed to embed HTML + JavaScript (JavaScript manages the
I am developing one small app in which i have multiple NSURLConnection.I have created
I've started developing a small app which main goal is to draw a map
I am developing a small web app that uses jQuery quite a lot. In

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.