Question

Hello I need help turning my code into a GUI applicaiton please. What I have for...

Hello I need help turning my code into a GUI applicaiton please. What I have for code and the requirements are below. Please please help, I will be so greateful. This is my last assignment of my school and I'm just so burnt out mentally that I don't know where to start and my teacher is always to busy to help. Thank you so so so much!

-----Code------
private void CalculateSC(ActionEvent event)
{
    if(amount < 10){
        chargeAmount = 1;
    }else if((amount > 10) && (amount < 100)){
        chargeAmount = (amount * 0.1);
    }else if((amount > 100) && (amount < 1000)){
        chargeAmount = 5 + (amount * 0.05);
    }else{
        chargeAmount = 40 + (amount * 0.01);
    }

-----Requirements-----

Part I (Coding Assignment) : Calculate the Service Charge - with GUI We would like to assess a service charge for cashing a check. The service charge depends on the amount of the check. Business Rules/Criteria: If the check amount is less than $10, we will charge $1. If the amount is greater than or equal to $10 but less than $100, we will charge 10% of the amount. If the amount is greater than or equal to $100, but less than $1,000, we will charge $5 plus 5% of the amount. If the value is over $1,000, we will charge $40 plus 1% of the amount. Display a pie chart that displays the % of checks cashed that are: less than $10 greater than or equal to $10 and less than $100 greater than or equal to $100 and less than $1000 greater than or equal to $1000 Other Requirements: GUI Notes: Capture check amount from user input (use a GUI text box) Use labels where needed to prompt user Display total in label Use a button to: Calculate the current check amount, service charge and the total, then Display graph with current % information Note: Use a multibranch if-else statement to compute the service charge. Note: Keep track of the current % amounts (continue to calculate total %)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import javax.swing.JOptionPane;
public class a {

public static void main(String[] args) {
String amountStr;
double amount,serviceCharge,total;
  
amountStr = JOptionPane.showInputDialog("Enter cheque amount: ");
amount = Double.parseDouble(amountStr);
  
serviceCharge = CalculateSC(amount);
total = amount + serviceCharge;
JOptionPane.showMessageDialog(null, "Cheque Amount : " + amount + "\nService Charge : "+serviceCharge+"\nTotal : "+total, "Results", JOptionPane.PLAIN_MESSAGE );
  
System.exit(0);
  
}
private static double CalculateSC(double amount)
{
double chargeAmount=0;
if(amount < 10){
chargeAmount = 1;
}else if((amount > 10) && (amount < 100)){
chargeAmount = (amount * 0.1);
}else if((amount > 100) && (amount < 1000)){
chargeAmount = 5 + (amount * 0.05);
}else{
chargeAmount = 40 + (amount * 0.01);
}
return chargeAmount;
}
}

Output:

Add a comment
Know the answer?
Add Answer to:
Hello I need help turning my code into a GUI applicaiton please. What I have for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java GUI Help! Hi, I have a Java GUI exercise that I need to complete and...

    Java GUI Help! Hi, I have a Java GUI exercise that I need to complete and was wondering if I could have a little bit of help... you can see it below. Create a simple graphical application that will enable a user to perform push, pop and peek operations on a stack and display the resulting stack (using toString) in a text area. Any help would be much appreciated! Thank you.

  • I need help with using the infile and outfile operations in C++... Here's my assignment requirements:...

    I need help with using the infile and outfile operations in C++... Here's my assignment requirements: Assignment: Cindy uses the services of a brokerage firm to buy and sell stocks. The firm charges 1.5% service charges on the total amount for each transaction, buy or sell. When Cindy sells stocks, she would like to know if she gained or lost on a particular investment. Write a program that allows Cindy to read input from a file called Stock.txt: 1. The...

  • I need to run each questions also with the outputs print 1. 3.1 Write an if...

    I need to run each questions also with the outputs print 1. 3.1 Write an if statement that assigns 0 to x when y is equal to 20. If (y == 20) X=0; 2. 3.2 Write an if statement that multiplies payRate by 1.5 if hours is greater than 40. If (hours > 40) payRate - payRate * 1.5; 3. 3.12 Write nested if statements that perform the following test: If amounti is greater than 10 and amount 2 is...

  • In java language here is my code so far! i only need help with the extra...

    In java language here is my code so far! i only need help with the extra credit part For this project, you will create a Rock, Paper, Scissors game. Write a GUI program that allows a user to play Rock, Paper, Scissors against the computer. If you’re not familiar with Rock, Paper, Scissors, check out the Wikipedia page: http://en.wikipedia.org/wiki/Rock-paper-scissors This is how the program works: The user clicks a button to make their move (rock, paper, or scissors). The program...

  • I need help in Python. This is a two step problem So I have the code...

    I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...

  • hello good night, could you help me to see what is wrong with my code, two...

    hello good night, could you help me to see what is wrong with my code, two errors appear at the bottom in red: In [47]: file_contents-open("color-blanco.png") def calculate_frequencies (file_contents): # Here is a list of punctuations and uninteresting words you can use to process your text punctuations = ""!()-[]{};:"",-./?@#$%^&*_~ uninteresting_words = ["the","in" ,"a", "to", "if", "is", "it", "of", "and", "or", "an", "as", "i", "me", "my", "we", "o # LEARNER CODE START HERE result={} a-file_contents.split() for word in a: if word...

  • (C#, Visual Studio) I need help modifying my program code to accommodate repeated numbers. For example,...

    (C#, Visual Studio) I need help modifying my program code to accommodate repeated numbers. For example, if a user inputs a repeated number the program should regenerate or ask to enter again. If needed, here is the program requirements: Create a lottery game application. Generate four random numbers, each between 1 and 10. Allow the user to guess four numbers. Compare each of the user’s guesses to the four random numbers and display a message that includes the user’s guess,...

  • I need help writing the code for a GUI calculator that uses 4 Radio Buttons (+....

    I need help writing the code for a GUI calculator that uses 4 Radio Buttons (+. -, * , /). Only one button can be selected at a time. I also have to group the buttons for this i am importing the ToggleGroup and using that. The user also need to select one function to begin with or an "Error" message will show if they select the calculate button. I would really like to know what needs to be used...

  • Java Homework Help. Can someone please fix my code and have my program compile correctly? Thanks...

    Java Homework Help. Can someone please fix my code and have my program compile correctly? Thanks for the help. Specifications: The class should have an int field named monthNumber that holds the number of the month. For example, January would be 1, February would be 2, and so forth. In addition, provide the following methods. A no- arg constructor that sets the monthNumber field to 1. A constructor that accepts the number of the month as an argument. It should...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT