Java Why Is My Java Program Not Working?

AI Thread Summary
The discussion focuses on a request for assistance in identifying mistakes in a Java program. Participants emphasize the importance of posting code within code tags instead of screenshots to facilitate easier quoting and analysis. Key errors identified include the incorrect use of method names in the Scanner class, specifically "nextInt()" and "nextDouble()" instead of "nextint()" and "nextdouble()", highlighting the significance of adhering to Java's naming conventions. Additionally, suggestions are made to improve variable naming practices and to consider using System.out.print(...) for input prompts instead of System.out.println(...) for aesthetic reasons. The thread concludes with a reminder to follow proper posting guidelines for future assistance.
grzz
Messages
1,030
Reaction score
26
TL;DR Summary
I need help because I cannot find mistakes in my java program.
Please help me to find what my mistakes are in the following java program.
 

Attachments

Technology news on Phys.org
From the next time onwards, please post your code inside the code tags instead of a screenshot. That helps us to directly quote portions of the code rather than typing out everything again. Click on this:

1672309365723.png


paste your code, select the language and click on Continue.

That aside, from your screenshot, I see BlueJ already highlights the errors. There is no function nextint() or nextdouble() in the Scanner class. It's nextInt() and nextDouble(). Note the capitals. These follow from the Java function naming conventions.

Also, it is better if you name objects using the naming conventions. sc (small letters) is better than Sc. In addition, when you are taking input, you can use System.out.print(...) instead of System.out.println(...). The last one is just for aesthetics, though.
 
  • Like
Likes FactChecker, jim mcnamara and pbuk
grzz said:
TL;DR Summary: I need help because I cannot find mistakes in my java program.

Please help me to find what my mistakes are in the following java program.
Please repost your thread using the instructions from @Wrichik Basu -- You really need to post the code within code tags if you want to get help at PF with your code. Please also tell us what you think is wrong with the code; are you getting errors?

This thread is closed.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top