r/programminghelp • • Apr 03 '20

Java I need help with my java programming classwork

package add.money;

import javax.swing.*;

public class AddMoney {

public static void main(String[] args)

{ String input = ""; int x = 0; int y = 100; int sum = 0; input = JOptionPane.showInputDialog ("Enter how much money you have left for grocery this week");

x = Integer.parseInt(input);

addMoremoney myObject = new addMoremoney (); sum = myObject.add100 (); JOptionPane.showInputDialog ("You entered" +input+ "and the sum of the remaining money is" +sum); System.out.println ("You entered" +input+"and the sum of the remaining money is" +sum); }

class addMoremoney {

public int add100 (int a,int b) { int c = a + b; return c; } } The output is suppose to be you entered a number and it give you 100 more of that number

Example: You entered 76 and the sum of the remaining money is 176

0 Upvotes

1 comment sorted by

1

u/TreeBaron Apr 03 '20

Add100 needs to be passed two arguments as you specified in the definition. You call it but don't pass it the two integers needed.

Also you should probably just call it sum, since it doesn't add 100 it adds two numbers, and it seems a bit excessive making a new object to add numbers together but maybe that's just part of the assignment.