Answered step by step
Verified Expert Solution
Link Copied!

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 in.There 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 =1b =2c =3...x =24y =25z =26Each 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 100.If reading a character causes the value to go over 100, 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 100, 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 4 of this character before going over the value 100. Once you read this 4th z and broke the 100 threshold, you would print out:Too Many 4
Java does not have a .nextChar() method. To read a char with a Scanner named in use: in.next().charAt(0). 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(0);
SAMPLE TEST CASES
Input:
a
a
a
a
!
Output:4
SAMPLE 2
Input:
f
d
r
!
Output: 28

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago