How to program an application for?

How to program an application for?

How do you write an application to count the number of both odd and even integers of several positive integerss? Then the final display is the total of how many odd numbers were entered and the total of how many even numbers were entered?
View Answers

May 27, 2010 at 10:57 AM

Hi Friend,

Try the following code:

import java.util.*;

class CountEvenAndOdd{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Enter 15 numbers");
int even=0,odd=0;
for(int i=1;i<=15;i++){
int num=input.nextInt();
if(num%2==0){
even++;
}
else{
odd++;
}
}
System.out.println("Number of Odds= "+odd);
System.out.println("Number of evens= "+even);
}
}

Thanks









Related Tutorials/Questions & Answers:
ModuleNotFoundError: No module named 'FORD'
how to use a image in background in your application form?
Advertisements
ModuleNotFoundError: No module named 'django-url-tracker-forl'
ModuleNotFoundError: No module named 'django-url-tracker-forl'
How to program an application for? - Java Beginners
ModuleNotFoundError: No module named 'ford-prefect'
How to create the program in Java for getting the forgotten Password Form?
preview and saving an application form
preview and saving an application form
Spring login form application
co.early.fore - fore-core-kt version 1.1.0 Maven dependency. How to use fore-core-kt version 1.1.0 in pom.xml?
ModuleNotFoundError: No module named 'fort'
Regarding Login application program
Write a java application program........?
ModuleNotFoundError: No module named 'fork'
GUI application program
College Application Program
Maven dependency for co.early.fore - fore-core-kt version 1.4.9 is released. Learn to use fore-core-kt version 1.4.9 in Maven based Java projects
Maven dependency for co.early.fore - fore-core-kt version 1.4.8 is released. Learn to use fore-core-kt version 1.4.8 in Maven based Java projects
Maven dependency for co.early.fore - fore-core-kt version 1.4.7 is released. Learn to use fore-core-kt version 1.4.7 in Maven based Java projects
Maven dependency for co.early.fore - fore-core-kt version 1.4.6 is released. Learn to use fore-core-kt version 1.4.6 in Maven based Java projects
Maven dependency for co.early.fore - fore-core-kt version 1.4.5 is released. Learn to use fore-core-kt version 1.4.5 in Maven based Java projects
Maven dependency for co.early.fore - fore-core-kt version 1.4.4 is released. Learn to use fore-core-kt version 1.4.4 in Maven based Java projects
Maven dependency for co.early.fore - fore-core-kt version 1.4.3 is released. Learn to use fore-core-kt version 1.4.3 in Maven based Java projects
Maven dependency for co.early.fore - fore-core-kt version 1.4.2 is released. Learn to use fore-core-kt version 1.4.2 in Maven based Java projects
ModuleNotFoundError: No module named 'fakear-fork'
ModuleNotFoundError: No module named 'isbnid_fork'
ModuleNotFoundError: No module named 'librabbitmq-fork'
ModuleNotFoundError: No module named 'LMSQuery-fork'
ModuleNotFoundError: No module named 'mockldap-fork'
ModuleNotFoundError: No module named 'onedrivesdk-fork'
ModuleNotFoundError: No module named 'papers-fork'
ModuleNotFoundError: No module named 'pocketsphinx-fork'
ModuleNotFoundError: No module named 'pocketsphinx-fork'
ModuleNotFoundError: No module named 'polyglot-fork'
ModuleNotFoundError: No module named 'polyglot-fork'
ModuleNotFoundError: No module named 'pyatmo-fork'
ModuleNotFoundError: No module named 'pybbm-fork'
ModuleNotFoundError: No module named 'pybitbucket_fork'
ModuleNotFoundError: No module named 'pybitbucket_fork'
ModuleNotFoundError: No module named 'pyloginsight-fork'
ModuleNotFoundError: No module named 'pyloginsight-fork'
ModuleNotFoundError: No module named 'pyppeteer-fork'
ModuleNotFoundError: No module named 'pysmithplot-fork'
ModuleNotFoundError: No module named 'pythonpy-fork'
ModuleNotFoundError: No module named 'talisker-fork'
ModuleNotFoundError: No module named 'toredis-fork'
ModuleNotFoundError: No module named 'zenoss-fork'
ModuleNotFoundError: No module named 'aiomeasures-fork'
ModuleNotFoundError: No module named 'aiomysql-fork'

Ads