A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

HW Help

4k views · started by Taz · · page 1 of 2
#1
HW Help
Help me really quick since i don't understand ish in Computer science and the teacher isnt very good at explaining shit.

Help me find whats wrong with this?

public class retail {

public static void main (String[] args);

//Get the user's amount of purchase.
System.out.print ("What was the amount of the purchase?");
amount = Keyboard.nextLine();




}



}


I will probably update this thread with more help but help me fast please so i can get this hw done before walking dead.
#2
Help with these 2 also.
"Write a program that asks the user for the number of miles driven and the gallon of gas used. It should calculate the car's miles per gallon and display the result on the screen."
MPG=Miles driven/ Gallons of gas used.

"Write a program that asks the user to enter three test scores. The program should display each test score, as well as the average of the scores."

Rep will be given if i can.
#3
you need to import a scanner and make a scanner
#4
Spammathon wrote:
you need to import a scanner and make a scanner


You are talking to a retard right now.
Simplify.
#5
import java.util.*; //at the beginning <--- Because I'll always forget something if import individual utilities

Scanner in (<-your variable here) = new Scanner(System.in); <- making the scanner inside the loop


so...

import java.util.*;

public class retail {

public static void main (String[] args);

//Get the user's amount of purchase.
Scanner Keyboard = new Scanner(System.in);
System.out.print ("What was the amount of the purchase?");
amount = Keyboard.nextLine();


//also, I have no idea if you actually NEED to do nextLine. Because if you want an "amount", I'm guessing nextInt is what your teacher is looking for..

}



}
#6
Oh yeah, and if your teacher dislikes .util*;


import java.util.Scanner; <- is the import for only scanners
#7
Its still saying its having problems with "System.out.print ("What was the amount of the purchase?");"
#8
I'm guessing if you understand scanners, you can do the 2nd real easily.

It's just taking two scanner inputs and dividing them.
#9
Taz wrote:
Its still saying its having problems with "System.out.print ("What was the amount of the purchase?");"



Oh, there's a " at the very end. My bad.

Actually, I didn't do that.

So...

Not my bad. XD
#10
Taz wrote:
Help me really quick since i don't understand ish in Computer science and the teacher isnt very good at explaining shit.

Help me find whats wrong with this?

public class retail {

public static void main (String[] args);

//Get the user's amount of purchase.
System.out.print ("What was the amount of the purchase?");
amount = Keyboard.nextLine();




}



}


I will probably update this thread with more help but help me fast please so i can get this hw done before walking dead.




And..... you're missing a bracket after public static void main (String[] args)

and that statement should not have a ;
#11
Spammathon wrote:
Oh, there's a " at the very end. My bad.

Actually, I didn't do that.

So...

Not my bad. XD


;( this is pretty hard shit but ima just try to do it on my own today but can you guys put all of them up for me so i can study them and try them later.
I also gave you reputation thanks for trying to help me :)
#12
thanks xD

good luck :/

the memorization of some things in the very beginning was hard for me too
I was forgetting brackets , quotation marks, case-sensitive words, etc..
#13
Spammathon wrote:
thanks xD

good luck :/

the memorization of some things in the very beginning was hard for me too
I was forgetting brackets , quotation marks, case-sensitive words, etc..


Hopefully i get it but i think im a bit behind because i am still waiting for my textbook to ship in.
#14
System.out.println ("What was the amount of the purchase?");
#15
So looking at your post, right away it doesn't seem like you have any kind of understanding of the basic concepts of the language at all.

If your teacher isn't very good and you prefer self-study I'd recommend Tutorials Point. They have a great introductory Java tutorial.

import java.util.Scanner;

public class Retail {
public static void main(String[] args) {
String amount;

Scanner Keyboard = new Scanner(System.in);

System.out.print("What was the amount of the purchase? ");
amount = Keyboard.nextLine();

//System.out.println("The amount of the purchase was " + amount);

}
}


https://gist.github.com/Isonyx/5158b3a813af1c659cd1

So, problems with the code.

Firstly, you didn't balance the braces for the main function. Every block needs to have an opening and closing brace. With a few exceptions such as if statements, but I won't go into that.

Secondly, you probably should have given the variable amount a type at the beginning of the program execution (main).
Although normally I would recommend giving it the value "double" or "float", we can't really do that here since the method you used to grab input from the user makes sure the user inputs a type of value known as a "string".
So instead we declare the storage container for the value the user wants to put in as a string.

Thirdly, you didn't tell Java what "Keyboard" was.
When you said Keyboard.nextLine you were basically invoking an operation if you will, that is an attribute of the object Keyboard. Because of this Java needs to know what Keyboard is.
Keyboard is going to be an object of the type "Scanner".
"Scanner" is not a "primitive data type" and thus not a core part of the language, therefore we need to import some files that tell us exactly what "Scanner" type object is. That's why I added the "import" section at the beginning of your code.

Thomas wrote:
System.out.println ("What was the amount of the purchase?");


This is unnecessary.

Also, I hope your assignment doesn't require you to do any kind of mathematical operation with that variable amount. Otherwise you'll need to reformat your code.

As for the other pieces of code, seriously, read the tutorial. Or find some other user to do your homework for you.
#16
I'm skipping to the bottom here and not reading any more posts after what was a chain of not the answer, so here:

public static void main (String[] args);

Should be a {, not a ;.
#17
I'm skipping to the bottom here and not reading any more posts after what was a chain of not the answer, so here:

public static void main (String[] args);

Should be a {, not a ;.

Multiple people already provided that answer.
#18
Isonyx wrote:
Multiple people already provided that answer.

tl;dr
#19
So much diff answers.
Yeah my teachr does suck because he tries to go through lessons so fast and get pissed when people asked questions knowing most of us are new to this.
Ill probably be looking through tuts later.
#20
tl;dr

Just regurgitating information huh?
#21
Isonyx wrote:
Just regurgitating information huh?

I don't think you know what regurgitating means.

I can't regurgitate if I don't first gurgitate.

Like I said, I didn't read anything for there to be anything to regurgitate.

Regurgitate
#22
*repeat
#23
I don't think you know what regurgitating means.

I can't regurgitate if I don't first gurgitate.

Like I said, I didn't read anything for there to be anything to regurgitate.

Regurgitate

Semantics. More appropriately I'll just say repeating, but for the record.

Regurgitate - "Repeat (information) without analyzing or comprehending it." - Merriam Webster

Doesn't seem like you read the posts that talked about the code error in question, therefore who's to say you didn't simply repeat the information without analyzing it let alone actually analyzing the entire first post which had more errors than one.
#25
Isonyx wrote:
Semantics. More appropriately I'll just saying repeating, but for the record.

Regurgitate - "Repeat (information) without analyzing or comprehending it." - Merriam Webster

Doesn't seem like you read the posts that talked about the code error in question, therefore who's to say you didn't simply repeat the information without analyzing it let alone actually analyzing the entire first post which had more errors than one.

Not analyzing something you have read isn't the same as not reading it.
#26
Not analyzing something you have read isn't the same as not reading it.


It doesn't have to be lol, you still didn't analyze it. The definition does not say "repeat (information) you have read without analyzing or comprehending it."
#27
CodingBat Java

really helps if you are trying to learn some java.
gives you some exercises !
#28
Isonyx wrote:
It doesn't have to be lol, you still didn't analyze it. The definition does not say "repeat (information) you have read without analyzing or comprehending it."

If you think you can regurgitate something you have never heard anyone say before, you need to stop being so pedantic with your definition. That is very obviously implied and can be seen in the context of the use of the word every time it's ever been used.
#29
If you think you can regurgitate something you have never heard anyone say before, you need to stop being so pedantic with your definition. That is very obviously implied and can be seen in the context of the use of the word every time it's ever been used.

I changed my original statement from regurgitating to repeating.
(Even with the definition of regurgitating being what it is.)
I was trying to let you know why I used the word I did, I had every right to be pedantic about things.
#30
Isonyx wrote:
I changed my original statement from regurgitating to repeating.
(Even with the definition of regurgitating being what it is.)
I was trying to let you know why I used the word I did, I had every right to be pedantic about things.

I mean, to be pedantic, everyone has a right to be pedantic about things. But did you have the justification? You did not.
#31
I mean, to be pedantic, everyone has a right to be pedantic about things. But did you have the justification? You did not.

If I'm trying to explain the reasoning behind why I used the word I did, I certainly don't see why I wouldn't have he justification to be pedantic about it.
#32
Isonyx wrote:
If I'm trying to explain the reasoning behind why I used the word I did, I certainly don't see why I wouldn't have he justification to be pedantic about it.

Because you were wrong? It's not regurgitation without first receiving input. Your explanation was "I thought regurgitate means something it doesn't" (merely to repeat versus repeating information first absorbed), which while an explanation isn't justification.
#33
Most pointless argument of the year. I nominate this one.
#34
Most pointless argument of the year. I nominate this one.

Being a dick is one thing. Being an incorrect dick is another.
#35



@Taz: Do you need to capitalize the "N" in "NextLine"?
#36
Being a dick is one thing. Being an incorrect dick is another.


I wasn't trying to be a dick, I was trying to point out that you posted information in the topic that had already been contributed.
You were the one who went out of his way to criticize my choice of words.

Let alone you (for some reason) assuming your opinion was the singularly correct and only answer to a question that had already been answered. Quit your bitching.
#37
I also said that I didn't read the above posts because there were too many replies to the OP to bother reading for such a simple answer that was requested. I checked the first five or six, and it wasn't mentioned. There were 10 more after that. So I stated in my first post why the content of my post might possibly be repeated information.

I was trying to point out that you posted information in the topic that had already been contributed.
You were the one who went out of his way to criticize my choice of words.

"Regurgitate" is literally an insult. Quit your bitching.
#38
I also said that I didn't read the above posts because there were too many replies to the OP to bother reading for such a simple answer that was requested. I checked the first five or six, and it wasn't mentioned. There were 10 more after that. So I stated in my first post why the content of my post might possibly be repeated information.


"Regurgitate" is literally an insult. Quit your bitching.

Lol your information was provided in the third post.
Regurgitate is an insult? Never heard it used that way.
If you took it as an insult I apologize, I wasn't trying to be insulting.
I was wondering why you did what you did.
Either way your answer was incomplete.
You should have read more posts as a way of informing yourself.
#39
This is just spam now, guys come on.

This is what I"m talking about. If the JY is going to be a shithole for trolls and fights now, then keep it in the JY.
Otherwise, you're spamming a non-spam section.
#40
Isonyx wrote:
Regurgitate is an insult? Never heard it used that way.

That is literally the only meaning it has outside of its literal interpretation of vomiting. As per the definition already quoted, it means to repeat something without being able to critically analyze or understand it. It's an insult to the person's ability to think critically. You probably shouldn't use words you don't know what mean for this very reason. It has never meant anything other than 1) to vomit or 2) to insult someone's comprehension skills.

I was wondering why you did what you did.

my very first post wrote:
I'm skipping to the bottom here and not reading any more posts after what was a chain of not the answer