Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
(Java) If Case Void Help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="St4nley" data-source="post: 227969" data-attributes="member: 31081"><p>[CODE]import java.util.Scanner; // IMPORT SCANNER</p><p></p><p>public class BasicCalculator {</p><p> public static void main(String[] args) {</p><p> Scanner Input = new Scanner (System.in); //DECLARING SCANNER VARIABLE</p><p> double firstNum, secondNum, answer; //DECLARING VARIABLES</p><p> double caseThird;</p><p> System.out.println("Enter First Number: ");</p><p> firstNum = Input.nextDouble(); //whatever i type in keyboard = firstNumber</p><p> System.out.println("Enter Second Number: ");</p><p> secondNum = Input.nextDouble(); //whatever i type in keyboard = secondNumber</p><p> answer = firstNum + secondNum;</p><p> System.out.println(answer);</p><p> </p><p> if (answer == 20) {</p><p> </p><p> System.out.println("Enter a Third Number");</p><p> caseThird = Input.nextDouble();</p><p> answer = firstNum + secondNum + caseThird;</p><p> System.out.print("The Total = ");</p><p> System.out.println(answer);</p><p> }else{</p><p> System.out.println("Null");</p><p> [/CODE]</p><p></p><p>right before the if statement it says print answer, BUT i want to void that print answer IF my if statement is in run. Is there any way to do this? </p><p>Thanks!</p></blockquote><p></p>
[QUOTE="St4nley, post: 227969, member: 31081"] [CODE]import java.util.Scanner; // IMPORT SCANNER public class BasicCalculator { public static void main(String[] args) { Scanner Input = new Scanner (System.in); //DECLARING SCANNER VARIABLE double firstNum, secondNum, answer; //DECLARING VARIABLES double caseThird; System.out.println("Enter First Number: "); firstNum = Input.nextDouble(); //whatever i type in keyboard = firstNumber System.out.println("Enter Second Number: "); secondNum = Input.nextDouble(); //whatever i type in keyboard = secondNumber answer = firstNum + secondNum; System.out.println(answer); if (answer == 20) { System.out.println("Enter a Third Number"); caseThird = Input.nextDouble(); answer = firstNum + secondNum + caseThird; System.out.print("The Total = "); System.out.println(answer); }else{ System.out.println("Null"); [/CODE] right before the if statement it says print answer, BUT i want to void that print answer IF my if statement is in run. Is there any way to do this? Thanks! [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
(Java) If Case Void Help
Top