• Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Have any question?

(+91) 98222 16647
info@simplycoding.in
RegisterLogin
Simply Coding
  • Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Java

Library Classes Programs

  • Categories Java, Wrapper Classes

1 . Write a program to assign character constants ‘A’, ‘d’, ‘5’ to the appropriate character variables and using character functions check the status of the letters and print the output in true or false.

public class problem1
{
   public void check()
   {
       char ch = 'D', ch1 = '8', ch2 = 'q';
       System.out.println( ch +" is a capital letter, the result is = "+Character. isUpperCase ( ch ));
       System.out.println( ch1 +" is a digit, the result is = "+ Character. isDigit ( ch1 ));
       System.out.println( ch2 +" is a small letter, the result is ="+ Character. isLowerCase ( ch2 ));
       System.out.println( ch +" is a small letter, the result is = "+Character. isLowerCase ( ch ));
       System.out.println( ch1 +" is an alphabet, the result is = "+Character. isLetter ( ch1 ));
   }
}

2 . Write a program to define a function void Show( char ch ) to print whether the character argument ch’ is an uppercase letter or a small letter or a letter/digit or space character.

public class problem2
{
   public void Show( char ch )
   {
       System.out.println( ch +" is a capital letter? -> the result is = "+ Character. isUpperCase( ch ));
       System.out.println( ch +" is a small letter? -> the result is = "+Character. isLowerCase( ch ));
       System.out.println( ch +" is a digit or letter? -> the result is = " + Character. isLetterOrDigit( ch ));
       System.out.println( ch +" is a space character? -> the result is =" + Character. isLowerCase(ch ));
   }
}

3 . Design a class printMessage with a function void message( ) with two print statements of your choice. Create another function void Result() to create an object of class and call the method to print messages.

public class printMessage
{
   public void message( )
   {
       System.out.println("Computer Application ");
       System.out.println("Programming is Fun ");
   }
   public static void Result()
   {
       printMessage obj = new printMessage( );
       obj. message( );
   }
}

4 . Write a program to initialize an uppercase character of your choice. Convert the character in lowercase form using character function. Print the original and new character with suitable headings.

public class problem4
{
   public void change_Character()
   {
       char ch = 'Q', newchar;
       newchar = Character. toLowerCase( ch );
       System.out.println("Original character = "+ ch );
       System.out.println("New character = " + newchar );
       }
}

5 . Write a program to initialize a lowercase character of your choice. Convert the character in uppercase form using character function. Print the original and new character with suitable headings.

public class problem5
{
   public void Change_Character()
   {
       char st = 'h', ds;
       ds = Character.toUpperCase( st );
       System.out.println("Original character = "+ st );
       System.out.println("New character = "+ ds );
   }
}

6 . A Class SalaryCalculation has been defined to calculate the total salary of an employee on the fixed salary and allowances.

The details of the class are as follows:

Class name                                          : SalaryCalculation

Data members/ Instance variables: codeNo (long integer type data)
                                                                 basicPay, specialAlw, coveyanceAlw; gross, pf,
                                                                 netSalary, AnnualSal (all double type data)

Methods / Members functions of the class :

(i) void giveValues( )                         : to assign data members codeNo (code
                                                                 number),basicPay (basic salary)with some
                                                                 values and Rs. 1000.00 as conveyanceAlw
                                                                 (conveyance allowance).

(ii) void SalaryCal()                          :to calculate other allowances and
                                                              salaries as given: specialAlw = 25% of
                                                              basic salary (basicPay).
                                                              gross = basicPay + specialAlw +conveyanceAlw.
                                                              pf = 8.33% of basicPay.
                                                              netSalary = gross – pf.
                                                              AnnualSal = 12 month netSalary.

(iii) void display()                           :to print codeNo along with other
                                                             data members with headings.
Define a main() function to create the object of the class and invoke the methods to calculate allowances, salary and print all the data of an employee.

public class SalaryCalculation
{
   long codeNo;
   double basicPay, specialAlw, conveyanceAlw, gross, pf, netSalary,AnnualSal;
   void giveValues()
   {
       codeNo = 32145;
       basicPay = 25000.0;
       conveyanceAlw = 1000.0;
   }
   void SalaryCal()
   {
       specialAlw = 0.25 * basicPay;
       gross = basicPay + specialAlw + conveyanceAlw;
       pf = (8.33/100.0) * basicPay;
       netSalary = gross -pf;
       AnnualSal = netSalary * 12;
   }
   void display()
   {
       System.out.println("Code number of the employee3 " + codeNo);
       System.out.println("Basic salary= " + basicPay );
       System.out.println("Special allowance= " + specialAlw );
       System.out.println("Conveyance allowance= " + conveyanceAlw );
       System.out.println("Gross salary= " + gross);
       System.out.println("Provident fund= "+pf );
       System.out.println("Net salary= "+ netSalary );
       System.out.println("Annual salary= " + AnnualSal );
   }
   public static void main()
   {
       SalaryCalculation obj = new SalaryCalculation();
       obj. giveValues();
       obj. SalaryCal();
       obj. display();
   }
}

7 . Example of AutoboxingUnboxing

public class AutoboxingUnboxing
{
   void AutoBoxing_UnBoxing()
   {
       char ch = 'F';
       int num = 70;
       double V = 848.20;
       Integer obj = new Integer( num );
       Double val = new Double( V);
       Character st = ch;
       System.out.println("Values after Autobexing :");
       System.out.println("Value of Wrapper class Integer object obj= " +obj);
       System.out.println("Value of Wrapper class Double object val= "+val);
       System.out.println("Value of Wrapper class Character object st= "+ st );
       ch = st;
       num = obj;
        V= val;
       System.out.println("Values after Unboxing below :");
       System.out.println("Value of primitive data type int num= "+num );
       System.out.println("Value of primitive data type double V=" + V );
       System.out.println("Value of primitive data type char ch=" + ch );
   }
}
  • Share:
author avatar
Simply Coding

Previous post

Learn Python for & while
June 19, 2021

Next post

Programs on Class as the Basis of all Computation
June 22, 2021

You may also like

Single Linked List Programs in Java
Single Linked List Programs in Java
28 August, 2021
Implementing Stack using Array in Java
Implementing Stack using Array in Java
28 August, 2021
Questions on Library classes
Questions on Library classes
4 July, 2021

Leave A Reply Cancel reply

You must be logged in to post a comment.

Categories

  • Uncategorized
  • Programs
    • Python
    • Java
  • Problems
    • Python
    • Java
    • Web Development
      • Internet
    • Emerging Technologies
  • Notes
    • General
    • QBasic
    • MS Access
    • Web Development
      • XML
      • HTML
      • JavaScript
      • Internet
    • Database
    • Logo Programming
    • Scratch
    • Emerging Trends
      • Artificial Intelligence
      • Internet of Things
      • Cloud Computing
      • Machine Learning
    • Computer Fundamentals
      • Computer Networks
      • E-Services
      • Computer Hardware
    • Python
    • Java
  • School
    • ICSE
      • Computers Class 9
        • Java Introduction
        • Tokens & Data Types
        • Java Operators
        • Math Library
        • if & switch
        • For & While
        • Nested loops
      • Computer Class 10
        • Sample Papers
        • OOPS concepts
        • Functions in Java
        • Constructors
        • Arrays in Java
        • Strings in Java
    • SSC
      • IT Class 11
        • IT Basics
        • DBMS
        • Web Designing
        • Cyber Laws
      • IT Class 12
        • Web Designing
        • SEO
        • Advanced JavaScript
        • Emerging Tech
        • Server Side Scripting
        • E-Com & E-Gov
      • Computer Science 11
      • Computer Science 12
    • CBSE
      • Computer 9
        • Basics of IT
        • Cyber Safety
        • Scratch
        • Python
      • Computer 10
        • Sample Papers
        • Networking
        • HTML
        • Cyber Ethics
        • Scratch
        • Python
      • Computer Science 11
        • Computer Systems
        • Python 11
          • Python Basics
          • Python Tokens
          • Python Operators
          • Python if-else
          • Python loops
          • Python Strings
          • Python List
          • Python Tuple
          • Python Dictionary
          • Python Modules
        • Data Management
      • Computer Science 12
        • Sample Papers
        • Python 12
          • Python Functions
          • Python File Handling
          • Python Libraries
          • Python Recursion
          • Data Structures
        • Computer Networks
        • Data Management
    • ISC
      • Computer Science 11
        • Introduction to Java
        • Values & Data Types
        • Operators
        • if & switch
        • Iterative Statements
        • Functions
        • Arrays
        • String
        • Data Structures
        • Cyber Ethics
      • Computer Science 12
        • Sample Papers
        • Boolean Algebra
        • OOPS
        • Wrapper Classes
        • Functions
        • Arrays
        • String

Categories

  • Uncategorized
  • Programs
    • Python
    • Java
  • Problems
    • Python
    • Java
    • Web Development
      • Internet
    • Emerging Technologies
  • Notes
    • General
    • QBasic
    • MS Access
    • Web Development
      • XML
      • HTML
      • JavaScript
      • Internet
    • Database
    • Logo Programming
    • Scratch
    • Emerging Trends
      • Artificial Intelligence
      • Internet of Things
      • Cloud Computing
      • Machine Learning
    • Computer Fundamentals
      • Computer Networks
      • E-Services
      • Computer Hardware
    • Python
    • Java
  • School
    • ICSE
      • Computers Class 9
        • Java Introduction
        • Tokens & Data Types
        • Java Operators
        • Math Library
        • if & switch
        • For & While
        • Nested loops
      • Computer Class 10
        • Sample Papers
        • OOPS concepts
        • Functions in Java
        • Constructors
        • Arrays in Java
        • Strings in Java
    • SSC
      • IT Class 11
        • IT Basics
        • DBMS
        • Web Designing
        • Cyber Laws
      • IT Class 12
        • Web Designing
        • SEO
        • Advanced JavaScript
        • Emerging Tech
        • Server Side Scripting
        • E-Com & E-Gov
      • Computer Science 11
      • Computer Science 12
    • CBSE
      • Computer 9
        • Basics of IT
        • Cyber Safety
        • Scratch
        • Python
      • Computer 10
        • Sample Papers
        • Networking
        • HTML
        • Cyber Ethics
        • Scratch
        • Python
      • Computer Science 11
        • Computer Systems
        • Python 11
          • Python Basics
          • Python Tokens
          • Python Operators
          • Python if-else
          • Python loops
          • Python Strings
          • Python List
          • Python Tuple
          • Python Dictionary
          • Python Modules
        • Data Management
      • Computer Science 12
        • Sample Papers
        • Python 12
          • Python Functions
          • Python File Handling
          • Python Libraries
          • Python Recursion
          • Data Structures
        • Computer Networks
        • Data Management
    • ISC
      • Computer Science 11
        • Introduction to Java
        • Values & Data Types
        • Operators
        • if & switch
        • Iterative Statements
        • Functions
        • Arrays
        • String
        • Data Structures
        • Cyber Ethics
      • Computer Science 12
        • Sample Papers
        • Boolean Algebra
        • OOPS
        • Wrapper Classes
        • Functions
        • Arrays
        • String
Simply Coding Computer Courses for School                Privacy Policy     Terms of Use     Contact Us

© 2021 Simply Coding

Login with your site account

Lost your password?

Not a member yet? Register now

Register a new account

Are you a member? Login now