Anyone can help me with my java

anyone can help me with my java

this science is too advanced

It should be this:

import java.util.*;
public class Exam1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
int num = Integer.parseInt(s.nextLine());
if (num >= 10 && num

>anyone can help me with my java
Yes anyone could because that's baby-tier programming. Whether it's homework or shitposting, take it elsewhere.

>count = count + num;

Yes, that's right. I don't know if Java lets you do += but it's the same either way.

>else {
break;
}

I really hope you were trolling OP.

Looks like it does let you do += now that I've Googled it. Not that it matters either way, but here you go:

import java.util.*;
public class Exam1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
int num = Integer.parseInt(s.nextLine());
if (num >= 10 && num

Yeah, get rid of the break, that's also wrong. Wasn't trolling, just didn't pay attention and kept that piece in from the original problem code. Here's another revision:

import java.util.*;
public class Exam1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
int num = Integer.parseInt(s.nextLine());
if (num >= 10 && num

>count += num;

Yeah, you're right. Here's another fix:

import java.util.*;
public class Exam1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
int num = Integer.parseInt(s.nextLine());
if (num >= 10 && num

>babbies first program
take it to or but this is easy as shit so you might get laughed at there too

computer science is not a real science

To be fair this isn't really a computer science question anyway.

>he doesn't check that the input is actually a number

Does Integer.parseInt not do that in Java? I don't know Java to be honest senpai, I'm just guessing based on the languages I do know.

I'll rewrite it in a second with that check though. Hold on.

Regardless of whether the parseInt function checks, you're using the number right after anyway. parseInt can't do anything for you at that point.

Yeah, I get it. You probably need to do something like this.

import java.util.*;
public class Exam1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
try{
int num = Integer.parseInt(s.nextLine());
} catch (NumberFormatException) {
System.out.print("That wasn't a number, what are you doing?");
}
if (num >= 10 && num

>printing the exception and then continuing right on anyway

Fine, how about this? I should really just get a Java compiler so I can keep on fucking up with feedback until it works:

import java.util.*;
public class Exam1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
try{
int num = Integer.parseInt(s.nextLine());
if (num >= 10 && num

>java

Fuck off.

I messed up several parentheses there, but you get the idea. Maybe more like this:

import java.util.*;
public class Exam1 {
public static void main(String[] args) {

Scanner s = new Scanner(System.in);
int count = 0;

for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
try{
int num = Integer.parseInt(s.nextLine());
if (num >= 10 && num

>letting i increment when the exception occurs, and thus preventing the user from entering the full 10 numbers.

I also can't continue unless you format that shit.

They shouldn't be allowed to enter any other numbers if they enter in a non-number.

Also try catch was an unnecessary tangent. The problem just said to find the errors, not providing a check for numbers isn't an error, it just isn't very user friendly when it throws an unhandled exception.

Your parentheses are screwed m8 and so is your try/catch, which is important to the question and I guarantee that whatever the solution is to that problem includes a quick error check.

If the user enters in a non-number they deserve to have their program crash.

>parentheses

OP can put it in whatever Java IDE he has and figure out where they're supposed to go.

Am I speaking to a new user right now?

No, I've just reached my limit for how willing I am to try to write shit Java syntax inside image board message boxes. I thought this was just going to be one or two lines that needed adjusting to solve the problem, but they slipped in problems everywhere and you're riding me about error checking on top of that when there isn't even any such check in the original code.

I misread your comment so don't worry about that.

>when there isn't even any such check in the original code

There are many things missing in the original code, which is the entire point of the question.

>I don't know how to program an introductory question so fuck it it's good enough

I can do it just fine in a reasonable language. Here.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace testing
{
class Program
{
static void Main(string[] args)
{
int count = 0;
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Enter number: ");
int num;
while (!Int32.TryParse(Console.ReadLine(), out num))
{
Console.WriteLine("That wasn't a number.");
}
if (num >= 10 && num