generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Need help with Java

Previous Thread :: Next Thread 
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
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
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
24 Nov 2015 03:04 PM
Oh, I thought you meant JavaScript.

http://www.roblox.com/siggy-item?id=322100454
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
24 Nov 2015 03:05 PM
myInput.nextInt();

P.S. Java sux don't use it
Report Abuse
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
24 Nov 2015 03:05 PM
it's a school assignment i have to use java :/
Report Abuse
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
24 Nov 2015 03:06 PM
@both where do i put that
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
24 Nov 2015 03:07 PM
//KNOWLEDGE
System.out.println("Input your Knowledge mark");
String kMark = myInput.nextInt();
Report Abuse
lordrambo is not online. 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
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
24 Nov 2015 03:08 PM
int kMark*
Report Abuse
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
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
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
24 Nov 2015 03:23 PM
b
Report Abuse
lordrambo is not online. 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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
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
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
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 is not online. 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
ChiefOrange is not online. ChiefOrange
Joined: 06 Mar 2011
Total Posts: 8385
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image