Why Is My Java Program Not Working?

In summary, there is a request for help in finding mistakes in a Java program. The conversation also includes tips on posting code correctly and following Java naming conventions. There is also a reminder to provide more information, such as any errors encountered.
  • #1
grzz
1,021
21
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

  • java progr.pdf
    38 KB · Views: 130
Technology news on Phys.org
  • #2
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
  • #3
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.
 

FAQ: Why Is My Java Program Not Working?

What is Java programming?

Java is a popular programming language that is used to create software applications and websites. It is a high-level, object-oriented language that is designed to be platform-independent, meaning that it can run on any operating system without needing to be rewritten. Java is used in a wide range of applications, from mobile apps to enterprise software.

How do I start learning Java programming?

There are many resources available for learning Java programming, including online tutorials, books, and courses. It is recommended to start with the basics of programming, such as understanding variables, data types, and control structures, before moving on to more advanced concepts. It is also helpful to practice writing and debugging code on your own, as this will help you gain a deeper understanding of the language.

What are the key concepts in Java programming?

Some key concepts in Java programming include objects and classes, which are used to create reusable code and organize data. Java is also known for its use of inheritance, polymorphism, and encapsulation, which allow for efficient and flexible code. Additionally, Java uses a virtual machine to run programs, which helps with its platform-independence.

What are the common challenges for beginners in Java programming?

Some common challenges for beginners in Java programming include understanding the syntax and structure of the language, debugging errors in code, and understanding more advanced concepts such as object-oriented programming. It is important to be patient and practice regularly in order to overcome these challenges.

How can I improve my skills in Java programming?

One of the best ways to improve your skills in Java programming is to practice regularly and challenge yourself with new projects. You can also read books and articles on advanced topics, attend workshops and conferences, and collaborate with other programmers. It is also helpful to constantly review and refactor your code to improve its efficiency and readability.

Similar threads

Replies
1
Views
2K
Replies
2
Views
2K
Replies
1
Views
1K
Replies
8
Views
3K
Replies
14
Views
1K
Back
Top