Video 19(ch4)Ps4

Yash
0

 






Program:-



import java.util.Scanner;
public class PS4v19 {
public static void main(String[] args) {
//Q1.what will be the output of this program.
/*int a = 10;
if(a==11)
System.out.println("I am 11");
else
System.out.println("I am not 11");*/
System.out.println("Question 1\n ");
int a = 10;
System.out.println("the output of the given program is :");
if(a==11)
System.out.println("I am 11\n\n");
else
System.out.println("I am not 11\n\n");
//Q2. write a program to find out wether a student is pass or fail; if it requires total 40% and at least 33% in each subject to pass. Assume 3 subjects and take marks as an input from the user.
System.out.println("Question2\n");
Scanner sc = new Scanner(System.in);
byte s1, s2, s3;
System.out.println("Enter the marks of PHYSICS:");
s1 = sc.nextByte();
System.out.println("Enter the marks of MATHS:");
s2 = sc.nextByte();
System.out.println("Enter the marks of CGEMISTRY");
s3 = sc.nextByte();
float per = (s1 + s2 + s3)/3.0f;
System.out.println("Your total percantage is:"+per+"\n");
if(per>=40 && s1>=33 && s2>=33 && s3>=33){
System.out.println("Congratulations, You have been promoted\n\n");
}
else{
System.out.println("Sorry, You have not been promoted! please try again\n\n");
}
 
 
/*Q3.calculate income the paid by an employe to the goverment as per the slas mentioned below:
income slals                Tax                                         2.5L-5.0L                        5%                                        5.0L-10.0L                      20%                                      above 10.0                    30%                            Note that there is no tax bleow 2.5L take input amount as an input form the user.*/
System.out.println("Question3\n");
System.out.println("enter your income in lacks:");
float tax = 0;
float income = sc.nextFloat();
if(income<=2.5){
     tax = tax + 0;
     }
    else if(income>2.5f && income<=5.0f){
         tax = tax + 0.05f  * (income - 2.5f);
         }
else if(income>5.0f && income<=10.0f){
    tax = tax + 0.05f  * (5.0f -  2.5f);
    tax = tax + 0.2f * (income - 5.0f);
    }
    else if(income>10.0f){
        tax = tax + 0.05f  * (5.0f -  2.5f);
        tax = tax + 0.2f * (10.0f - 5.0f);
        tax = tax + 0.3f * (income - 10.0f);
        }
        System.out.println("Total tax paid by the employe is:" + tax+"L\n\n");
        
        //Q4.write a java program to find out the day of the week given the number[1 for monday 2 for tuesday____ and so on].
            System.out.println("Qestion4\n");
        int day = 2;
        switch(day){
            case 1:
            System.out.println("monday");
            break;
            case 2:
            System.out.println("tuesday\n\n");
            break;
            case 3:
            System.out.println("wednesday");
            break;
            case 4:
            System.out.println("thrusday");
            break;
            case 5:
            System.out.println("friday");
            break;
            case 6:
            System.out.println("saturday");
            break;
            case 7:
            System.out.println("sunday");
            break;
            }
            //5.write a java program to find wether a year entered by the user is a leap year or not.
            System.out.println("Question5\n");
            System.out.println("Enter the year to be checked:"); 
            int yr = sc.nextInt();
            if(yr%4==0 && yr%100!=0 || yr%400==0){
                System.out.println(yr+" is a leap year\n\n");
                }
                else{
                    System.out.println(yr+" is not a leap year\n\n");
                    }
                    
       /*6.write a program to find oit tye type of website from the url.
       ©.com->commercial website.
       ©.org->organizational website.
       ©.in->indian website.*/
        System.out.println("Question6\n");
        System.out.print("Enter your website name:");
       String website = sc.next();
       if(website.endsWith(".org"))
       {
           System.out.println("This is an organizational website");
           }
           else if(website.endsWith(".com"))
           {
                System.out.println("This is an commercial website");
               }
               else if(website.endsWith(".in"))
               {
                    System.out.println("This is an indian website");
                   }                 
}
}
Tags

Post a Comment

0 Comments
Post a Comment (0)
To Top