Okay so basiclly my problem is I cant figure out how to properly modulus three variables. Since I am very new to java it would be much easier if I just post my problem!
MessageBoxProgram_float.doc
These are my directions ^^^^
This is what I'm having trouble doing in the directions: Add the first 2 numbers and Modulus by the third number, store the result in fresult.
And this is my code:
//CISS-110-361 //Jacob Lindsay //Coding Assignment 3 - Three Numbers import javax.swing.JOptionPane; public class MessageBoxProgram { public static void main(String[] args) { String snum1, snum2, snum3; //Variables float fnum1, fnum2, fnum3, fresult; //Get variables from user and store them snum1 = JOptionPane.showInputDialog("Please enter a deciaml number "); fnum1 = Float.parseFloat(snum1); snum2 = JOptionPane.showInputDialog("Please enter second deciaml number "); fnum2 = Float.parseFloat(snum2); snum3 = JOptionPane.showInputDialog("Please enter third deciaml number "); fnum3 = Float.parseFloat(snum3); //Perform calculations fnum3%= (fnum1 + fnum2); fresult = fnum3; //Display user input numbers JOptionPane.showMessageDialog(null,"Your numbers were: " + snum1 +", " + snum2 +", " + snum3); //Show result of calculations JOptionPane.showMessageDialog(null,"The result is " + fresult ); String.format("%.2f"); } }
Please I dont understand how to do the modulus on the two other numbers! I am so stumped its not even funny! This is an assignment due tonight so it would be greatly appreciated if someone could help me(The directions in the word file will help understand what im trying to do!)!