I got the easy part, the sum of all numbers between the first integer and second integer, but I need to sum all the odd integers between the first and second.
// ***********************
// * *
// * LAB05A.java, CSc 15 *
// * *
// ***********************
import java.util.Scanner;
public class Lab05A
{
public static void main(String[] args)
{
// Variables
int start;
int end;
int count;
int sum;
Scanner keyboard = new Scanner(System.in); //input - java scanner
// PROGRAM START
System.out.print("What is the beginning number: ");
start = keyboard.nextInt();
System.out.print("What is the end number: ");
end = keyboard.nextInt();
sum = 0;
count = start;
while (count <= end)
{
sum = sum + count;
count++;
}
System.out.println("The sum of all integers between " + start + " and " + end + " is " + sum + " (inclusively).");
System.out.println("The count value is " + count + ".");
}
}


Sign In
Create Account


Back to top









