Computer Applications
Define a class to accept a String and print if it is a Super String or not. A String is Super if the number of uppercase letters are equal to the number of lowercase letters. [Use Character and String methods only]
Example: “COmmITmeNt”
Number of uppercase letters = 5
Number of lowercase letters = 5
String is a Super String
Java
Java String Handling
14 Likes
Answer
import java.util.Scanner;
class SuperString{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Enter the string: ");
String s = in.nextLine();
int upper = 0;
int lower = 0;
int l = s.length();
for(int i = 0; i < l; i++){
char ch = s.charAt(i);
if(Character.isUpperCase(ch))
upper++;
else if(Character.isLowerCase(ch))
lower++;
}
if(upper == lower)
System.out.println("String is a Super String");
else
System.out.println("String is not a Super String");
}
}Output
![BlueJ output of Define a class to accept a String and print if it is a Super String or not. A String is Super if the number of uppercase letters are equal to the number of lowercase letters. [Use Character and String methods only] Example: “COmmITmeNt” Number of uppercase letters = 5 Number of lowercase letters = 5 String is a Super String BlueJ output of Define a class to accept a String and print if it is a Super String or not. A String is Super if the number of uppercase letters are equal to the number of lowercase letters. [Use Character and String methods only] Example: “COmmITmeNt” Number of uppercase letters = 5 Number of lowercase letters = 5 String is a Super String](https://cdn1.knowledgeboat.com/img/abp10/1/2025-p3.jpg)
Answered By
6 Likes
Related Questions
Define a class named CloudStorage with the following specifications:
Member Variables:
int acno – stores the user’s account number
int space – stores the amount of storage space in GB purchased by the user
double bill – stores the total price to be paid by the user
Member Methods:
void accept() – prompts the user to input their account number and storage space using Scanner class methods only.
void calculate() – calculates the bill total price based on the storage space purchased using the pricing table provided:Storage range Price per GB (Rs) First 15 GB 15 Next 15 GB 13 Above 30 GB 11 void display() – displays the account number, storage space and bill to be paid.
Write a main method to create an object of the class and invoke the methods of the class with respect to the object.
Define a class to accept values into a 4 × 4 integer array. Calculate and print the NORM of the array.
NORM is the square root of sum of squares of all elements.1 2 1 3 5 2 1 6 3 6 1 2 3 4 6 3Sum of squares of elements = 1 + 4 + 1 + 9 + 25 + 4 + 1 + 36 + 9 + 36 + 1 + 4 + 9 + 16 + 36 + 9 = 201
NORM = Square root of 201 = 14.177446878757825Define a class to initialize the following data in an array.
Search for a given character input by the user, using the Binary Search technique.
Print “Search successful” if the character is found otherwise print “Search is not successful”.
‘A’, ‘H’, ‘N’, ‘P’, ‘S’, ‘U’, ‘W’, ‘Y’, ‘Z’, ‘b’, ‘d’Define a class to overload the method print() as follows:
void print() – To print the given format using nested loops.@#@#@ @#@#@ @#@#@ @#@#@double print(double a, double b) – To display the sum of numbers between a and b with difference of 0.5.
e.g. if a = 1.0, b = 4.0
Output is: 1.0 + 1.5 + 2.0 + 2.5 + … + 4.0
int print(char ch1, char ch2) – Compare the two characters and return the ASCII code of the largest character.