Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class EXAM4 { public static void main(String[] args) { // Use a Common Scanner for all Section A,B,C,D Scanner in = new

import java.util.Scanner; public class EXAM4 { public static void main(String[] args) { // Use a Common Scanner for all Section A,B,C,D Scanner in = new Scanner(System.in); /**------------------ Part A - Input integers and print the smallest and largest integer entered Terminate input and print results when operator enters any letter */ //Identify your variables int largest=-10000; int smallest=10000; //Ask for Input System.out.print("Enter a number from -9999 to 9999 , enter any letter to print results: "); //Loop - While Loop terminates when no integer entered while (in.hasNextInt()) { int input = in.nextInt(); if (input > largest) { largest = input; } if (input < smallest) { smallest = input; } } // Print the results System.out.println("Largest: " + largest + " " + "Smallest: " + smallest); /**------------------------ Part B - Input integers (ranging from -9999 to 9999) and print the number of even and odd inputs Terminate input and print results when operator enters anything other than an integer */ //Identify your variables //Ask for Input Once //Loop - While loop terminates when no integer entered // Print the results /**--------------------------- Part C - Input integers and print running totals For example if 1,7,2,9 are entered, you print 1,8,10,19 (Hint: Print will be inside while loop) Terminate input and print results when operator enters anything other than an integer */ //Identify your variables //Ask for Input Once //Loop - While loop terminates when no integer entered // Print the results /**---------------------------- Part D - Input 10 integers all adjacent duplicates. Use a FOR loop- No error checking for this one - Just assume all inputs are integers For example if 1,3,3,4,5,5,6,6,6,2 are entered, you print 3,5,6 (Hints: Compare previous input to next input, Print will be inside FOR loop) */ //Identify your variables //Ask for Input Once //Loop - FOR Loop - terminates after 10 integers are entered // Print the results in.close(); } }. Copy paste the code from the the attached start file into EXAM4 class, follow the instructions to complete PARTS B,C,D using the same structure as done in PART A.

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions