java - How do I make this if statement? -
Sorry for the silly question, I am currently struggling to learn Java. I need this code to work, as long as '0' is not entered for the student number, it will continue to repeat, I am uncertain to ensure that "Please enter the" student number "section How should I work to get it, when I have to declare int for this statement? I am not sure what I have done completely or wrongly, but to repeat the data entry No need to be competent, unless "0" is not entered as a student number Thanks for any help!
class main {public static zero main (string agr []} {Int studentNumber = BIO.getInt (); if (studentNumber> 0) {System.out.print ("# Please enter student number:"); System.out.print ("#" Please enter the coursework mark Enter: "); Int courseWork = BIO.getInt (); System.out.print (Enter the" # Examination Mark: "); Int Exam Mark = BIOGETINT (Double) = (Double) (Core Servers + Examination Mark) / 2; System.out.printf ("sn =" + StudentNumber + "ex =" + + Exam Mark + "cw =" + courseWork + "mark =" + average); } Else {System.out.print ("Data End #"); }}}}}
use while () Instead of if , with the following changes:
System.out.print ("# Please enter student number:"); Int studentNumber = BIO.getInt (); While (studentNumber & gt; 0) {System.out.print ("# Please enter coursework icon:"); Int courseWork = BIO.getInt (); System.out.print ("# Examination Marks:"); Int Exam mark = BIOGETINT (); Double average = (double) (coursework + test mark) / 2; System.out.printf ("sn =" + studentNumber + "ex =" + test mark + "cw =" + courseWork + "mark =" + average); System.out.print ("Enter # Student Number:"); StudentNumber = BIO.getInt (); } System.out.print ("End of data #"); This, unlike other answers, will ensure that even in the first walk, you prompt (and prompts the user for student numbers).
Comments
Post a Comment