Write a program to convert the month and days into number of the days for year 2010.
Example: Input Month and days: May 16
import java.util.Scanner;
public class A129323{
public static void main(String [] args){
int i = 0, numberOfDays = 0, sum = 0, previousMonth = 0, count = 0;
Scanner input = new Scanner(System.in);
System.out.println("Input Month and days: ");
int month = input.nextInt();
int days = input.nextInt();
while(i<=month)
{
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
{
numberOfDays = 31;
}
if (month == 4 || month == 6 || month == 9 || month == 11)
{
numberOfDays = 30;
}
if (month == 2)
{
numberOfDays = 28;
}
i++;
}
sum = numberOfDays + (days - 1);
System.out.println("Output: " + sum );
}}
this is what i had been type...
when i compile my answer can't count the previous months day...