|
| 24 Nov 2015 03:03 PM |
It's giving me an error "The operator * is undefined for the argument type(s) java.lang.String, double", and it's highlighting the "String kEnd = (kMark * kWeight);" part. Anyone know what the problem is? ;/
import java.util.Scanner; import java.io.*;
public class A2_MarkCalculator_UmarM_v1 { public static void main(String[] args) throws IOException { BufferedReader myInput = new BufferedReader (new InputStreamReader (System.in)); //Weighted Averages double kWeight = 0.29; double cWeight = 0.14; double aWeight = 0.29; double tWeight = 0.29;
//KNOWLEDGE System.out.println("Input your Knowledge mark"); String kMark = myInput.readLine(); System.out.println("What is your Knowledge mark out of?"); String kTotal = myInput.readLine();
//COMMUNICATION System.out.println("Input your Communication mark"); String CMark = myInput.readLine();
System.out.println("What is your Communication mark out of?"); String CTotal = myInput.readLine(); //APPLICATION System.out.println("Input your Application mark"); String AMark = myInput.readLine(); System.out.println("What is your Application mark out of?"); String ATotal = myInput.readLine(); //THINKING System.out.println("Input your Thinking mark"); String TMark = myInput.readLine(); System.out.println("What is your Thinking mark out of?"); String TTotal = myInput.readLine(); String kEnd = (kMark * kWeight); System.out.println(kEnd); } }
|
|
|
| Report Abuse |
|
|
|
| 24 Nov 2015 03:04 PM |
Oh, I thought you meant JavaScript.
http://www.roblox.com/siggy-item?id=322100454 |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2015 03:05 PM |
myInput.nextInt();
P.S. Java sux don't use it |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2015 03:05 PM |
| it's a school assignment i have to use java :/ |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Nov 2015 03:07 PM |
//KNOWLEDGE System.out.println("Input your Knowledge mark"); String kMark = myInput.nextInt(); |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Nov 2015 03:08 PM |
the input you are taking in is in the form of a string
either use nextInt/nextDouble functions or cast the string to an integer but this is stupid |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Nov 2015 03:12 PM |
| now i'm getting the error "The method nextInt() is undefined for the type java.io.BufferedReader" |
|
|
| Report Abuse |
|
|
| |
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Nov 2015 03:33 PM |
change BufferedReader myInput = new BufferedReader (new InputStreamReader (System.in)); to Scanner myInput = new Scanner(System.in);
|
|
|
| Report Abuse |
|
|
|
| 24 Nov 2015 03:33 PM |
I think he mean myInput.readInt()
Instance.new("BodyVelocity",SenseiWarrior).velocity = CFrame.new(SenseiWarrior.Torso.Position,YourGirlsDMs.Position).lookVector * 10 |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2015 03:38 PM |
omg it worked thanks lord
if i used int it would return "0.0" so I changed it to double to account for the decimals and it worked :D!
|
|
|
| Report Abuse |
|
|
|
| 24 Nov 2015 03:49 PM |
FINISHED MY ASSIGNMENT A DAY EARLY THANKS GUYS! FINAL PRODUCT:
//Umar Malik //Monday November 13 2015 //Make a mark calculator that takes weighted averages into account
import java.util.Scanner; import java.io.*;
public class A2_MarkCalculator_UmarM_v1 { public static void main(String[] args) throws IOException { Scanner scanIntData = new Scanner(System.in); Scanner myInput = new Scanner(System.in); //Weighted Averages double kWeight = 0.285714285; double cWeight = 0.142857142; double aWeight = 0.285714285; double tWeight = 0.285714285;
//QUESTIONS: //KNOWLEDGE System.out.println("Input your Knowledge mark"); double kMark = myInput.nextDouble(); System.out.println("What is your Knowledge mark out of?"); double kTotal = myInput.nextDouble();
//COMMUNICATION System.out.println("Input your Communication mark"); double cMark = myInput.nextDouble();
System.out.println("What is your Communication mark out of?"); double cTotal = myInput.nextDouble(); //APPLICATION System.out.println("Input your Application mark"); double aMark = myInput.nextDouble(); System.out.println("What is your Application mark out of?"); double aTotal = myInput.nextDouble(); //THINKING System.out.println("Input your Thinking mark"); double tMark = myInput.nextDouble(); System.out.println("What is your Thinking mark out of?"); double tTotal = myInput.nextDouble();
//MATH: double kFinal = ((kMark / kTotal) * kWeight); double cFinal = ((cMark / cTotal) * cWeight); double aFinal = ((aMark / aTotal) * aWeight); double tFinal = ((tMark / tTotal) * tWeight); System.out.println((kFinal + cFinal + aFinal + tFinal) * 100);
} } |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Nov 2015 04:15 PM |
| I'm curious what class this was for. Just a generic high school java class, APCS? Probably not college level but who knows. |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2015 04:33 PM |
im grade 11 and this is my first year taking computer programming so maybe taking university level wasn't such a good idea XD
i'm canadian and it's just grade 11 university introductory computer science |
|
|
| Report Abuse |
|
|