freelanceprogrammers.org Forum Index » Java
INPUT AND OUTPUT PROGRAM
Joined: 08 Feb 2002
Posts: 6
INPUT AND OUTPUT PROGRAM
I am trying to create a program that accept
charracter from keyboard and print the result<br>such
variables as: Quizes = .30, homework = .20,<br>cummulative
= .30, midterm = .20<br>I want to write this
program to accept input(marks) for each variable and
multiply it by the corresponding constant. Then sum up the
total scores<br><br>Can someone help out? <br>thank you
in advance
Joined: 30 Jan 2002
Posts: 24
INPUT AND OUTPUT PROGRAM
To slove your problem,i don`;t think it`s
difficult.<br>For your first quesiton,use java.io class to get the
input which you input from keyboard.And use some
methods to change to the form which you want.<br>Be
carefull that ,which the System.in get is a string,so you
should use ,such like parseInt,or other to chage into
the int or float.
Joined: 08 Feb 2002
Posts: 8
INPUT AND OUTPUT PROGRAM
import java.io.*;public class G{public static
void main(String[] args){<br>System.out.println("Grade
is "
+<br>(g("Quizes")*0.3+g("Homework")*0.2+g("Cummulative")*0.3+g("Midterm")*0.2));
}<br>public static double g(String s){<br>StreamTokenizer t =
new StreamTokenizer(new
InputStreamReader(System.in));<br>try{System.out.println("Enter score for
"+s+"...");t.nextToken();}<br>catch
(IOException e){System.out.println(e);}return
t.nval;}}<br><br>Now your homework is to figure out the spacing...
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







