Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I NEED THIS CODE WRITTIN IN JAVA!!!! In this program, you will be reading a series of characters from input and measuring the value of
I NEED THIS CODE WRITTIN IN JAVA!!!!
In this program, you will be reading a series of characters from input and measuring the value of the characters passed inThere will be a series of n lowercase characters provided via standard input. You will read these n characters and measure the value of each of these individual characters using the following key of values:a b c x y z Each of these characters will be on an individual line by themselves. The input will be terminated with the character on the final line of standard input.You must keep track of the total value as you read each character. Your reading of the characters will be terminated in one of two ways. The first is that you will read all of the characters from input and output the final value of all of them collectively with a newline after this number. The second is that you will terminate early because the total goes over If reading a character causes the value to go over you will print two lines of text to output. The first line will read Too Many and have a newline follow it The second line will be how many characters were read up to the point of going over the total of value of including the character which caused the overage. A newline will follow this.An example of this would be reading in a series of the character z from input. You would read of this character before going over the value Once you read this th z and broke the threshold, you would print out:Too Many
Java does not have a nextChar method. To read a char with a Scanner named in use: innextcharAt You can assign to char variable.
Use single wuotes for charcter literals. You use normal comparison operators like and to compare charcters for equivalence.
If you wish to terminate a program eariler you can use System.exit;
SAMPLE TEST CASES
Input:
a
a
a
a
Output:
SAMPLE
Input:
f
d
r
Output:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started