Posts

Find out whether the given input is letter or digit

 Program to find whether a given character is a digit or a letter import  java . util . Scanner ; //Importing Scanner class to get input from the user public class  Identify {             public static void main(String []args)   // Main method     {         char a ;                   System.out.println ("Enter digit or a letter");  //Instruction to User          a  =  new  Scanner ( System.in ). next().charAt(0) ;                   if (( a >'a' &&  a <'z')||( a >'A' &&  a <'Z'))         {              System.out.println ("This is a letter");  //If the given character is letter         }       ...

Calculate the final price of the Laptop or Desktop after certain discount of total cost according to criteria

Image
An electronics shop has announced the following seasonal discounts on the purchase of certain items.  Purchase Amount in Rs.  Discount on Laptops Discount on Desktop PC  0 - 25,000 0.0% 5.0% 25,001 – 57,000  5.0%  7.5%  57,001 – 1,00,000 7.5%  10.0%  More than 1,00,000  10.0%  15.0% At first Scanner class is called to read the value from the user. Then Required variables are declared. Then String type is declared to enter the section of the laptop or desktop. Then according to the question if the given string is L,l then the program enters into laptop section otherwise it enters int desktop section. you need some data and instruction from the user in this program So, you need to import the  Scanner  class. Here ' Scanner ' class, the built-in class inside the ' util ' package of ' java ' project is importe...

calculate the total tax charged(According to different tax rate)

Calculate the total tax amount charged This program is to calculate the total tax amount charged on the income of a person on the basis of given criteria. Total Annual Taxable Income Tax Rate Upto Rs.1,00,000 No tax From 1,00,001 to 1,50,000 10% of the income exceeding Rs.1,00,000 From 1,50,000 to 2,50,000 Rs.5000 +20% of the income exceeding Rs.1,50,000 Above Rs.2,50,000 Rs.25,000 +30% of the income exceeding Rs.2,50,000   import  java . util . Scanner ;   public  class  Employee {        int  pan;  //declaring variable        String  name;  //declaring variable        double  taxIncome ;  //declaring variable        double  tax =0;  //declaring variable         public void   input()   //Creating Non return type input method        {          ...

program to find the displacement

Calculate the Displacement using initial velocity, acceleration and, time taken  The data like(initial velocity, acceleration and, time taken ) needed to calculate simple interest can be initialized with the default value inside the class and also can be taken from the user. Here ' Scanner ' class, the built-in class inside the ' util ' package of ' java ' project is imported to get value from the keyboard. import   java . util .Scanner;  //Calling Scanner class public  class  Displacement {      //Declaring Variables      double  u;  //Initial velocity      double  t;  //Time taken      double  a;  //Acceleration      public static void main(String []args)     {           Scanner obj=new Scanner(System.in);  //Creating object of Scanner class          ...

Convert input string into Uppercase

Convert Input string into Uppercase  There are many built-in classes in the Java programming language. ' String ', ' Scanner ', ' Math '   are some of out of all the built-in classes inside the Java programming language. And here you need ' String ' class to convert the input string into Uppercase which is present inside the ' lang '   package of the ' java ' project. All the built-in classes in Java contain many methods which are helpful to perform the mentioned specific task. So to convert the inputted string into uppercase you need to call  toUpperCase() method from the String class. And is done by the keyword called  ' import '. import   java . lang . String ; //Importing String class from lang package import  java . util . Scanner ; //Importing Scanner class from util package public  class StringToUC {      public static void main(String []args)     {           String ...

program to convert days into year month and days

Convert days into year month and days import  java.util. Scanner ; public  class  DateConv {      int  Totaldays;      int  year;      int  mon      int  days;      public static void main(System []args)     {           System.out.println ("Enter total days to be converted months and days");           //Creating anonymous object for the built-in class  ' Scanner'           int  number=  new   Scanner (System.in).nextInt();          if  (number>0)          {                 DateConv  obj=  new   DateConv ();                obj. setTotaldays (number);  //Calling setTotaldays me...

biggest number among two rolled dice

Image
Biggest number among two rolled dice When you rolled two different dice then this is the program to identify the winning number out of the two different dice rolled numbers. import java.util.Scanner; //Calling Scanner Class public class PairOfDice {     //Declaring Variables      private int a;      private   int  b;     public void DiceRolled()    {         System.out.println ("Enter first rolled number"); //Instruction for User        a=new Scanner(System.in).nextInt(); //Getting value of First rolled dice        System.out.println("Enter Second rolled number"); //Instruction for User        b=new Scanner(System.in).nextInt(); //Getting value of Second rolled dice         //Condition to meet the criteria tobe the number of dice         if ((a>=1 && a<=...