0

i plan to display all of the odd number, and sum all of the odd number.
please check with my code, there is something wrong...:)

import java.util.Scanner;

public class testing {

    public static void main(String[] args) {
		int sum = 0;

		Scanner scan = new Scanner(System.in);
    	System.out.printf("Enter minimum number: ");
    	int min_Num = scan.nextInt();
    	System.out.printf("Enter maximum number: ");
    	int max_Num = scan.nextInt();

		if(min_Num / 2 != 0)
			for(min_Num <= max_Num)
			{
				System.out.println(min_Num + ", ");
				sum += min_Num;
				min_Num += 2;
			}

    }
}
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by gahhon
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.