Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is what I have so far. I'm not sure how to get the program to display the total amount of odd numbers in the

image text in transcribedimage text in transcribed

This is what I have so far. I'm not sure how to get the program to display the total amount of odd numbers in the file/ how to get the second method to recognize "n". Thanks for your help!

/* This program helps the user to determine whether the number is a odd number. In order to do so, you need to (1) create a class called "homework5_1" (2) read the number from a file called "numbers.txt" one by one in the main method (3) determine whether the number is a odd number in a seperate method called "isodd". The method returns "true" if it is a odd number, and "false" otherwise. Here is the logic to determine odd number: In java, \% means modulus, which takes the remainder from division. For example 5%3=2. Odd number means a number modulus 2==1 (number\%2 ==1 or number\%2 !=0 ) (4) determine the number of odd number in this file Here are the examples: Example 1: numbers in the input file, "numbers.txt": 1, 2, 3, 4, 5 output: 3 Example 2: numbers in the input file, "numbers.txt": 1,3,5,7,9,11,13,15,17,19 output: 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions