How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask R.R. Jha Your Own Question

R.R. Jha
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5470
Experience:  B.Tech
20870358
Type Your Homework Question Here...
R.R. Jha is online now
A new question is answered every 9 seconds

import java.awt.*;import java.awt.event.*;import javax.swing.*;

Resolved Question:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class StateIncome extends JFrame implements ActionListener {

private JTextField salary = new JTextField(20), interest = new JTextField(20),
deductions = new JTextField(20), exemptions = new JTextField(20),
taxWithheld = new JTextField(20), refund = new JTextField(20);
private JButton compute = new JButton("Compute Refund");

public StateIncome(){

super ("Calculate Your State Refund");
setSize(350,250);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout(7,2));
add(new JLabel("Salary Income: "));add(salary);
add(new JLabel("Interest Income: "));add(interest);
add(new JLabel("Itemized Deductions: "));add(deductions);
add(new JLabel("Exemptions: "));add(exemptions);
add(new JLabel("Tax Withheld: "));add(taxWithheld);
add(new JLabel(""));add(compute);
add(new JLabel("Refund: "));add(refund);
refund.setEditable(false);
compute.addActionListener(this);

}

@Override
public void actionPerformed(ActionEvent event){

double grossIncome = Double.parseDouble(salary.getText())+Double.parseDouble(interest.getText());
double taxableIncome = grossIncome - Double.parseDouble(deductions.getText())- (Double.parseDouble(exemptions.getText())* 2700);
double taxOwed = 0;

}

public static void main(String[] args) {

StateIncome frame = new StateIncome();
frame.setVisible(true);
}

}
Submitted: 1 year ago.
Category: Homework
Expert:  Josie-Mod replied 1 year ago.
Hello,

I'm Josie and I'm a moderator for this topic.

We have been working with our professionals to try to help you with your question. Sometimes it may take a bit of time to find the right fit.

I was checking to see if you had already found your answer or if you still need assistance from one of our professionals.

Please let me know if you wish to continue waiting or if you would like for us to close your question?

Also remember that JustAnswer has a multitude of categories to help you with all your needs from Pet to Legal.

Thank you,

Josie~Moderator
Expert:  Mr. Gregory White replied 1 year ago.
Hello, my name is Greg.

Thanks for asking your programming prompt. Many experts have reviewed your question so far, but no one at this time has felt comfortable trying to help. The question may be just to difficult or not informative enough or priced to low.
Can you provide the specifics of what you are needing for this assignment as what you have provided above does not really show what is required. The more information you can provide, the easier it will be to find an expert who is best able to support your needs.
You can upload using a file sharing site such as mediafire.com or wikisend.com and then share the link here with us.
Hopefully someone will be able to provide a response to you soon.
Customer: replied 1 year ago.

The third programming project involves writing a program to calculate the terms of the following sequence of numbers: 0 1 2 5 12 29 ... where each term of the sequence is twice the previous term plus the second previous term. The 0th term of the sequence is 0. The interface to the program should be a GUI that looks similar to the following:

The pair of radio buttons allows the user to choose whether an iterative or recursive method is used to compute the term of the sequence. When the user enters a value for n and then clicks the Compute button, the nth term of the sequence should be displayed in the Result field. The Efficiency field should contain the number of calls to the recursive method when the recursive option is chosen and the number of iterations of the loop when the iterative option is selected.

The Iterative radio button should be initially set to selected.

You should run your program with values for n from 0 to 10 and record and graph the value of the Efficiency field for both the iterative and recursive options. The graph should be contained in a Word document that also contains a brief explanation of the observed results. That document must also be submitted with the code for this project.

This is what i need thanks

Expert:  R.R. Jha replied 1 year ago.
Hi there,

I can help with your third programming project, but it's rather time taking for the original value of this question. Let me know if you could add $25 as bonus and I'd start working on this soon after.


Thanks
Customer: replied 1 year ago.
Yeah I can add 25 dollars and its due next week so no rush
Expert:  R.R. Jha replied 1 year ago.
Thanks. I'll send the program by tomorrow.
Customer: replied 1 year ago.
Also can u make sure u name all variables fully no abriviations. And any constants name those as well
Expert:  R.R. Jha replied 1 year ago.
Ok
Customer: replied 1 year ago.
U can't answer the question?
Expert:  R.R. Jha replied 1 year ago.
I'm working on it, would post the answer by tonight.
Customer: replied 1 year ago.
Sorry got a message saying u couldn't do it
Customer: replied 1 year ago.
So how's everything going
Customer: replied 1 year ago.
It's tonight what's up
Expert:  R.R. Jha replied 1 year ago.
Finished most of it, would complete it in about an hour.
That message was automated, which I guess is sent when a question hasn't been answered for some days.
Expert:  R.R. Jha replied 1 year ago.
Please download the code below

https://www.box.com/s/4ibundvecd5jmz4rccy7

Please leave a rating for the answer, and thanks in advance for the bonus.

Let me know when you need help with other problems. Just add 'RRJha' at the start of your new question to send it directly to me.


Thanks
Customer: replied 1 year ago.

You should run your program with values for n from 0 to 10 and record and graph the value of the Efficiency field for both the iterative and recursive options. The graph should be contained in a Word document that also contains a brief explanation of the observed results. That document must also be submitted with the code for this project.


 


How do i do this part just run it and just make a graph and put it in a word document.

Expert:  R.R. Jha replied 1 year ago.
Ok, I'd do that and get back to you.
Customer: replied 1 year ago.

really thanks just wondering how though

Expert:  R.R. Jha replied 1 year ago.
I'm doing it using Microsoft Excel.
Customer: replied 1 year ago.
Ahh
Expert:  R.R. Jha replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5470
Experience: B.Tech
R.R. Jha and 5 other Homework Specialists are ready to help you
Customer: replied 1 year ago.

Thanks that looks great.


 

Customer: replied 1 year ago.

I need ur help. The efficiency button everytime you press the compute button the result is ok but the efficiancy if you press the compute button just add on and dosent clear for another number in the n space.

Expert:  R.R. Jha replied 1 year ago.
Couldn't understand what the problem is. Everything is working fine here. Efficiency value of are all correct, they'll increase successively if you increase N, or decrease successively if you decrease N.
If you want the value of N to clear in the text box, just add this below line#89, that is, this is last statement of function actionPerformed()

txtN.setText("");

Customer: replied 1 year ago.
Yeah it works fine but in efficiency line. If u have a different number in n block the effiancy block doesn't reset
Customer: replied 1 year ago.
It just add to it if u don't close the program and enter a different number in enter n. the results fine but efficacy just adds more that line need to reset like result does
Expert:  R.R. Jha replied 1 year ago.
Here results and efficiency are both correctly changing. Could you please give an example what are you entering for N and what result and efficiency are you getting?
Customer: replied 1 year ago.

Ok, How to explanine in the enterN textfield you enter 5. the radio button is on recursuve, you hit compute button the result is 29 which is fine and the efficiancy is 15 which is good to. Now without exiting the program type in two. hit computer the result is 2 efficiancy is 18 which is not good it should be 3. Thats the issue.

Expert:  R.R. Jha replied 1 year ago.
Here it's correctly showing 3. Checked the code too, it's as it should be. Please make sure you're using the code I sent as is. I guess, the problem occurs if you're making efficiency a static variable. So, please check that it isn't so. Also, check if line #81 is

efficiency = 0;

As we're resetting efficiency, it shouldn't add previous values.
Customer: replied 1 year ago.

I found that out already. And I changed your code a bit but it still works. That what i was missing. How does this look?



import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Sequence extends JFrame implements ActionListener {

private final int TWICE = 2;
private JLabel jLabel1 = new JLabel(), jLabel2 = new JLabel(), jLabel3 = new JLabel(),
jLabel4 = new JLabel(), jLabel5 = new JLabel(), jLabel6 = new JLabel();
private ButtonGroup radioButtons = new ButtonGroup();
private JRadioButton rbIterative = new JRadioButton(), rbRecursive = new JRadioButton();
private JTextField enterN = new JTextField(16), textResult = new JTextField(16),
textEfficiency = new JTextField(16);
private JButton computeBut = new JButton();
private int efficiency;

public Sequence() {

super("Sequence of Numbers, Iterative, Recursive!");
setSize(300, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new GridLayout(6, 2));
getContentPane().add(jLabel4);

radioButtons.add(rbIterative);
rbIterative.setSelected(true);
rbIterative.setText("Iterative");
getContentPane().add(rbIterative);
getContentPane().add(jLabel5);

radioButtons.add(rbRecursive);
rbRecursive.setText("Recursive");
getContentPane().add(rbRecursive);

jLabel1.setText("Enter n: ");
getContentPane().add(jLabel1);
getContentPane().add(enterN);
getContentPane().add(jLabel6);


computeBut.setText("Compute");
computeBut.addActionListener(this);
getContentPane().add(computeBut);

jLabel2.setText("Result: ");
getContentPane().add(jLabel2);
getContentPane().add(textResult);
textResult.setEditable(false);

jLabel3.setText("Efficiency: ");
getContentPane().add(jLabel3);
getContentPane().add(textEfficiency);
textEfficiency.setEditable(false);

pack();

}

public void actionPerformed(ActionEvent event) {
int result;
efficiency = 0;
if (rbIterative.isSelected()) {
result = doIterative(Integer.parseInt(enterN.getText()));
} else {
result = doRecursive(Integer.parseInt(enterN.getText()));
}
textResult.setText(Integer.toString(result));
textEfficiency.setText(Integer.toString(efficiency));

}

private int doIterative(int n) {
int result = 0;

if (n == 0) {
result = 0;
} else if (n == 1) {
result = 1;
} else {
int secondPrevious = 0;
int previous = 1;
for (int i = TWICE; i <= n; i++) {
efficiency++;
result = TWICE * previous + secondPrevious;
secondPrevious = previous;
previous = result;
}
}
return result;


}

private int doRecursive(int n) {
int result;

efficiency++;
if (n == 0) {
result = 0;
} else if (n == 1) {
result = 1;
} else {
result = TWICE * doRecursive(n - 1) + doRecursive(n - 2);
}
return result;


}

public static void main(String[] args) {
Sequence frame = new Sequence();
frame.setVisible(true);
}
}

Expert:  R.R. Jha replied 1 year ago.
Looks good.
Customer: replied 1 year ago.
I asked another question no one answered it yet

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3458
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3124
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2385
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1988
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1876
    Bachelors Degree and CPA with Accounting work experience
  • http://ww2.justanswer.com/uploads/avremote/photoa.jpg Seanna's Avatar

    Seanna

    Tutor

    Satisfied Customers:

    1781
    3,000+ satisfied customers, all topics, A+ work
 
 
 

Related Homework Questions

Chat Now With A Tutor
R.R. Jha
R.R. Jha
Tutor
5470 Satisfied Customers
B.Tech