Please help:) write a java program that reads two integers as start and last. within that ranges, it should differentiate ODD values and EVEN values and display the separated list on screen with the sum of ODD and sum of EVEN. the program will be repeated until the termination condition is given by the user(Hint:if both start and last integer are equal then the program will terminate)

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Please help:) write a java program that reads two integers as start and last. within that ranges, it should differentiate ODD values and EVEN values and display the separated list on screen with the sum of ODD and sum of EVEN. the program will be repeated until the termination condition is given by the user(Hint:if both start and last integer are equal then the program will terminate)

Computer Science
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

This is vat I hav done so far. import java.io.*; public class Problem_a { public static void main(String[]args) throws IOException { BufferedReader keyboard=new BufferedReader (new InputStreamReader(System.in)); int a_1;//First term int a_n;//Last term int n;//Number of odd and even numbers available within the range int odd; int even; int sum_1=0;//Sum of odd numbers int sum_2=0;//sum of even numbers System.out.print("Enter the first number:"); a_1=Integer.parseInt(keyboard.readLine()); System.out.print("Enter the last number:"); a_n=Integer.parseInt(keyboard.readLine()); n=((a_n-a_1)/2)+1; if(((a_1%2==1) && (a_n%2==0)) || ((a_1%2==0) && (a_n%2==1))) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j<=n;j++) { even=(a_1+((j-1)*2))+1; System.out.print(" "+even+" "); sum_2+=even; } System.out.print("\n"); System.out.print(sum_2); } else if(a_1%2==1 && a_n%2==1) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j
@Chris2332 please help me:)
@eSpeX please help.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Sorry, computer stuff is out of my range of expertise.
That's k. Thanx a lot for taking a look.:)
what are you looking for? be concise ...
ah ... my bad. I don't have jdk installed ... hold on for few min.
oh k:)
I don't have fast connection ... perhaps it would take more than half hour ... can you summmarize what are you trying to do. I haven't programmed java for quite a long time.
I need to display the odd numbers and the even numbers between two numbers and also their sum seperately. When I compile the above program the output comes right. bt i have to include a condition that the program will be repeated until the termination condition is given by the user(Hint:if both start and last integer are equal then the program will terminate)
I hav no idea what that condition will be.
why not wrap the whole program in while loop?
or ... set the condition true ... inside while loop. use if start == final ... break; inside while loop.
hope this part is correct int sum_1=0;//Sum of odd numbers int sum_2=0;//sum of even numbers System.out.print("Enter the first number:"); a_1=Integer.parseInt(keyboard.readLine()); System.out.print("Enter the last number:"); a_n=Integer.parseInt(keyboard.readLine()); n=((a_n-a_1)/2)+1; if(((a_1%2==1) && (a_n%2==0)) || ((a_1%2==0) && (a_n%2==1))) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j<=n;j++) { even=(a_1+((j-1)*2))+1; System.out.print(" "+even+" "); sum_2+=even; } System.out.print("\n"); System.out.print(sum_2); } else if(a_1%2==1 && a_n%2==1) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j
while(true) { // first of all input the integers if start == final break; } rewrite that whole thing inside this loop.
gotta go out for a while ... brb in an hour.
ha k. Thanx a lot:)
import java.io.*; public class Problem_a { public static void main(String[]args) throws IOException { BufferedReader keyboard=new BufferedReader (new InputStreamReader(System.in)); int a_1;//First term int a_n;//Last term int n;//Number of odd and even numbers available within the range int odd; int even; int sum_1=0;//Sum of odd numbers int sum_2=0;//sum of even numbers while(true) { System.out.print("Enter the first number:"); a_1=Integer.parseInt(keyboard.readLine()); System.out.print("Enter the last number:"); a_n=Integer.parseInt(keyboard.readLine()); n=((a_n-a_1)/2)+1; if(((a_1%2==1) && (a_n%2==0)) || ((a_1%2==0) && (a_n%2==1))) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j<=n;j++) { even=(a_1+((j-1)*2))+1; System.out.print(" "+even+" "); sum_2+=even; } System.out.print("\n"); System.out.print(sum_2); } else if(a_1%2==1 && a_n%2==1) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j
seems it is working
put this thing right after you input it if (a_1 == a_n) { break; }
import java.io.*; public class Test { public static void main(String[]args) throws IOException { BufferedReader keyboard=new BufferedReader (new InputStreamReader(System.in)); int a_1;//First term int a_n;//Last term int n;//Number of odd and even numbers available within the range int odd; int even; int sum_1=0;//Sum of odd numbers int sum_2=0;//sum of even numbers while(true) { System.out.print("Enter the first number:"); a_1=Integer.parseInt(keyboard.readLine()); System.out.print("Enter the last number:"); a_n=Integer.parseInt(keyboard.readLine()); if (a_1 == a_n) { break; } n=((a_n-a_1)/2)+1; if(((a_1%2==1) && (a_n%2==0)) || ((a_1%2==0) && (a_n%2==1))) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j<=n;j++) { even=(a_1+((j-1)*2))+1; System.out.print(" "+even+" "); sum_2+=even; } System.out.print("\n"); System.out.print(sum_2); } else if(a_1%2==1 && a_n%2==1) { for(int i=1;i<=n;i++) { odd=a_1+((i-1)*2); System.out.print(" "+odd+" "); sum_1+=odd; } System.out.print("\n"); System.out.println(sum_1); for(int j=1;j
Ya it works perfectly nw:D. Thank u sooooooooooo much.:D That was a bigg help.

Not the answer you are looking for?

Search for more explanations.

Ask your own question