Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package PreSession_05;
- import java.util.Scanner;
- public class p4_1d {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int total=0;
- Scanner sc = new Scanner(System.in);
- System.out.println("Please input the begining value...");
- int a=sc.nextInt();
- System.out.println("Please input the Ending Value...");
- int b=sc.nextInt();
- do
- {
- if (a%2==1)
- {
- System.out.println(a);
- total=total+a;
- a++;
- }
- else
- {
- a++;
- }
- }while (a<=b);
- System.out.println();
- System.out.println("Total = "+total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement