Directions...Write a program SumOfOdds that has one main method that asks the user to input two odd integers where the first is smaller than the second. The program ouputs the sum of all the odd integers from the smaller output to the larger output. You must use a while loop for this program.:)

import javax.swing.JOptionPane;
public class SumOfOdds {

    public static void main (String[] args)
	{
		String number = JOptionPane.showInputDialog("Enter Number 1: ");
		double number = Double.parseDouble(input);
		String number = JOptionPane.showInputDialog("Enter a number that is greater than Number 1: ");
		double number = Double.parseDouble(input);
		SumOfOdds sum = new Sum(number);
    	while (num1<num2)
			if (num1%2==1)&&(num2%2==1)
    		{

    		}
		System.exit(0);
    }
}
TheSilentGiant commented: You do not specify what you need done. +0

Recommended Answers

All 4 Replies

And your question is?

I guess your question is how to make it work?

Well, here is a few problem with your code:

blablabla...

I guess your question is how to make it work?

You shouldn't have to "guess". What I am getting at is he should be posting a full "problem" description, not just describing what is supposed to happen and then a blurb of code that may, or may not, have been written by the OP, and then expect everyone to "finish" the code for them without even any hint as to what is still missing, or wrong.

You shouldn't have to "guess". What I am getting at is he should be posting a full "problem" description, not just describing what is supposed to happen and then a blurb of code that may, or may not, have been written by the OP, and then expect everyone to "finish" the code for them without even any hint as to what is still missing, or wrong.

I guess you were right after all(sorry for guessing again lol). I agree finishing the program for him does not make him learn anything.

@TigerTeck: You should start learning the basic of programming. My advice is when you learn one thing, start practise with it. Do not proceed if you still didn't get the previous lesson. Honestly, I learned a lot from Youtube since my lecturer sucks. You should check it out there too if you have some time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.