Write a Java program to meet the following requirements:
1. Prompt the user to enter three strings by using nextLine(). Space can be part of the string). ( Note: your program requires using loop: for-loop, while-loop or do-while-loop to get the input String )
2. Write a method with an input variable (string type).The method should return the number of lowercase letters of the input variable.
3. Get the number of the lowercase letters for each user input string by calling the method.
4. Compare the lowercase numbers and display the maximum, minimum lowercase numbers and the strings
5. You need to have proper comments.
6. You must use below testing data (copy and paste) to test your program.
Test input number: 12345
Check INPUT String: abc
MAXIMUM number
import java.util.*;
public class Main
{
//2
//method to find number of lower case letters in given input
variable
static int count_lowercase(String x)
{
int c=0;
for(int i=0;i<x.length();i++)
{
char d= x.charAt(i);//getting each char in x
if(97<=d && d<123)//if it is lowercase then
c++;//increasing count
}
return c;//returning count
}
public static void main(String[] args) {
//1
Scanner sc = new
Scanner(System.in);//to read input
System.out.println("Enter 3 strings
in each line:");
String s[]=new String[3];
for(int i=0;i<3;i++)
s[i]=sc.nextLine();//reading
strings
int max,min,maxc,minc;//declaring
required variables
max=min=0;
int
c=count_lowercase(s[0]);//calling method for string1
int
c2=count_lowercase(s[1]);//calling method for string2
if(c<c2)//finding min and max
string with lower case letters
{max=1;
maxc=c2;
minc=c;
}else
{max=0;
maxc=c;
minc=c2;
}
c2=count_lowercase(s[2]);//calling
method for string3
if(maxc<c2)//finding min and max
string with lower case letters
{max=2;
maxc=c2;
}
else if(c2<minc)
{
minc=c2;
min=2;
}
//now displaying output
System.out.println("String with max
lower case letters :"+s[max]+" count:"+maxc);
System.out.println("String with min
lower case letters :"+s[min]+" count:"+minc);
}
}
output:
Enter 3 strings in each line:
Hi
Hello
How are you
String with max lower case letters :How are you count:8
String with min lower case letters :Hi count:1
Write a Java program to meet the following requirements: 1. Prompt the user to enter three...
Java Write a program that prompt the user to enter a decimal number representing the radius of a circle. If the number is greater or equal to zero, the program displays the area of the circle. Otherwise, the program displays “negative input”
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to input 10 int numbers from the user...
In the first task, you will write a Java program that accepts a string of the format specified next and calculate the answer based on the user input. The input string should be of the format dddxxdddxx*, where d represents a digit and x represents any character and asterisk at the end represents that the string can have any number of characters at the end. 1. Prompt the user to enter a string with the specific format (dddxxdddxx*) 2. Read...
Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...
In Java please: Write a program that will prompt the user to enter GPA values one per line, stopping when the user enters a negative Input: value. Print the following on separate lines: . The number of vaild GPAs entered » The sum of the GPAs 4.0 3.7 2.9 3.5 -1 The average GPA
Prompt the user to enter two character strings. The program will then create a new string which has the string that appears second, alphabetically, appended to the end of the string that shows up first alphabetically. Use a dash (-') to separate the two strings. You must implement the function string appendStrings(string, string), where the return value is the combined string. Display the newly created string. Your program must be able to handle both uppercase and lowercase characters. You are...
Write a program that will loop ten times. In each iteration prompt user to enter an integer between -50&50. Print the input, keep a running sum of the inputs, and track the minimun and maximum numbers input. After the loop is complete, minimum number entered, maximum number entered, sum of all numberes entered, and average of all numbers entered. Format all output. Before running the loop, print the label "Input values: ". Within the loop, print value entered by user...
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.
I have to write a program in java which uses while loops. 1.prompt the user to input two intergers: firstnum ans second numnumber. (first number must be smaller that the second number). 2. Output all the even numbers between first number and second number inclusive. 3. Output the sum of all the even number between first number and second number inclusive. 4 Output all the odd numbers between first number and second number inclusive. 5. Output the sum of all...
Write a java program to prompt the user to enter three doubles and compute the sum and product. Print "The sum is 999 and the product is 999.", where 999 is replaced with the user sum and product.