how start doing on java, mean, start 2 diferent variables? 1 int (which whole numbers, such age , social number) , string or else words inputs.
and after reading that, have take avarage age in "group" of people used program also, show total number of people participated.
my concept went bit this:
import java.util.*; public class apple { public static void main(string args []) { scanner input = new scanner(system.in); int age, snum; string sex, exp = yes or no; //aaand donno how proceed here. >*< } }
personally, wouldn't shove in main method.
i'd have class called say:
person, has private variables name, gender, age etc. , you'd have public modifier methods (your sets , gets)
for example:
public class demo { private string fred; public void setfred(string thefred) { fred = thefred; } public string getfred() { return fred; } }
then you'd have generic input method inside class, deal input you'd like:
public void getinput() { // input stream...then do: system.out.println("please enter name: "); person.setname(scanner.getstring()); // or whatever need data entered. // , repeat... }
and in static main then, call getinput method, way learn write proper methods, , code simpler understand (at least in view)
Comments
Post a Comment