Page 50 - CTS - CSA TP - Volume 2
P. 50
COMPUTER SOFTWARE APPLICATION - CITS
if (console == null) {
System.out.println(“Console not available. Exiting...”);
System.exit(1);
}
// Read a password without displaying it on the console
char[] passwordChars = console.readPassword(“Enter your password: “);
String password = new String(passwordChars);
// Display a confirmation message
System.out.println(“Password entered: “ + password);
}
}
Output:
Related Exercises:
Question1: Create a program that stores information about your favorite book. Use appropriate data types for
the title (String), author (String), publication year (int), and price (double). Display the book details on the console.
Question 2: Write a program to calculate the area and perimeter of a rectangle. Prompt the user to enter the
length and width using the Scanner class and display the result.
Question 3: Design a class representing a basic bank account. Use instance variables to store the account
holder’s name, account number, and balance. Implement a method to deposit money into the account and display
the updated balance.
Question 4: Develop a program that reads the user’s Name, Age, and favorite color using the Scanner class and
display it.
Question 5: Develop a program to perform all Simple Arithmetic Operations.
Question 6: Create a program to Swap two numbers.
Question 7: Develop a program to convert the temperature in Celsius to Fahrenheit
Question 8: Create program to calculate area and circumference of a circle.
Question 9: Develop a program to calculate the interest (I=PNR where P=Principle Amount,N=No. of years,
R=Rate of interest)
Question 10: Develop a program to display the Product Details (Read Product_Code, Product_Name,Unit_Price
and Quantity. Calculate the Total_Price).
35
CITS : IT & ITES - Computer Software Application - Exercise 84 CITS : IT & ITES - Computer Software Application - Exercise 84