Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

INPUT AND OUTPUT PROGRAM

  Asked By: Daisy    Date: May 31    Category: Java    Views: 5954
  

I am trying to create a program that accept
charracter from keyboard and print the result such
variables as: Quizes = .30, homework = .20, cummulative
= .30, midterm = .20 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 Can someone help out?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Huette Miller     Answered On: May 31

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.

 
Answer #2    Answered By: Maria Miller     Answered On: May 31

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...

 
Didn't find what you were looking for? Find more on INPUT AND OUTPUT PROGRAM Or get search suggestion and latest updates.




Tagged: