Posts

Showing posts from 2020

Java Program to Find Roots of Quadratic Equation

import java.util.*; class testing {         public static void main(String args[])         {             double d,a,b,c,r1,r2;             Scanner sc=new Scanner(System.in);             System.out.println("Enter a:");             a=sc.nextDouble();             System.out.println("Enter b:");             b=sc.nextDouble();             System.out.println("Enter c:");             c=sc.nextDouble();             d=(Math.pow(b,2))-4*a*c;             if(d>0)             {                 r1=(-b+Math.sqrt(d))/(2*a);                 r2=(-b-Math.sqrt(d))/(2*a);                 System.out.println("1st root="+r1);                 System.out.println("2nd root="+r2);             }             else if(d==0)             {                 r1=-b/(2*a);                 System.out.println("1st root="+r1);             }             else             {                 System.out.println("Imaginary Roots");

Write a Program To Input the Marks and Display the Grades Accordingly using if-else in Java

import java.util.*; class Marks {     public static void main(String args[])     {         int m;         Scanner sc=new Scanner(System.in);         System.out.println("Enter the Marks:");         m=sc.nextInt();         if(m>=80)         {             System.out.println("Distinction");         }         else if(m>=60 && m<80)         {             System.out.println("First Division");         }         else if(m>=45 && m<60)         {             System.out.println("Second Division");         }         else if(m>=40 && m<45)         {             System.out.println("Pass");         }         else         {             System.out.println("Promotion Not Granted");         }     } }         OUTPUT: Enter the Marks: 90 Distinction YouTube Videos for Explanation https://www.youtube.com/watch?v=aqNaKEncMVE

WAP to input the total cost and to compute and display the Amount to be paid after the discount on the cost of purchased items, based on the following criteria:

WAP to input the total cost and to compute and display the Amount to be paid after the  discount on the cost of purchased items, based on the following criteria:         Cost                                            Discount (in percentage) Less than or equal to Rs. 10000                               5% More than Rs. 10000 and less than or equal to Rs. 20000       10% More than Rs. 20000 and less than or equal to Rs. 35000       15% More than Rs. 35000                                           20%*//*WAP to input the total cost and to compute and display the Amount to be paid after the  discount on the cost of purchased items, based on the following criteria:         Cost                                            Discount (in percentage) Less than or equal to Rs. 10000                               5% More than Rs. 10000 and less than or equal to Rs. 20000       10% More than Rs. 20000 and less than or equal to Rs. 35000       15% More than Rs. 35000         

Marquee Tag in Html and Properties of Marquee Tag with Html Code

<!DOCTYPE html> <html> <head> <title>Marquee Tag Example</title> </head> <body> <marquee behavior="scroll" scrollamount="10" direction="right" loop="3">Welcome To Coding Hub</marquee> </body> </html>

LIST Tags in Html

<!DOCTYPE html> <html> <head> <title>Example of List</title> </head> <body> <center><h1>Type of List</h1></center> <!--Order list--> <ol type=a> <li>Ajit</li> <li>Sahbaj</li> <li>Pawan</li> </ol> <ol type=A> <li>Ajit</li> <li>Sahbaj</li> <li>Pawan</li> </ol> <ol type=i> <li>Ajit</li> <li>Sahbaj</li> <li>Pawan</li> </ol> <ol start="10"> <li>Ajit</li> <li>Sahbaj</li> <li>Pawan</li> </ol>   <!--Unorder List--> <ul type="square">     <li>Ajit</li> <li>Sahbaj</li> <li>Pawan</li> </ul> <!--Defination List--> <dl> <dt>Ajit</dt> <dd>he is game De

A Computer Salesman gets commission on the following basis using Java

/*A computer salesman gets commission on the following basis:             Sales                        Commission Rate             Rs. 0 - 20,000                      3%             Rs. 20,000 - 50,000                12%             Rs. 50,001 and more                31% After accepting the sales as input, calculate and print his commission amount and rate of commission.*/ Source code: import java.util.*; class Comm {     public static void main(String args[])     {         double comm=0.0;         int rate=0,sale;         Scanner sc=new Scanner(System.in);         System.out.println("Enter the sales rs:");         sale=sc.nextInt();         if(sale<=20000)         {             rate=3;             comm=sale*0.3;         }         if(sale>=20000 && sale<=50000)         {             rate=12;             comm=sale*0.12;         }         if(sale>=50000)         {             rate=31;             comm=sale*0.31;         }  

Electricity Bill Program:Write a program in JAVA to enter the unit and calculate the amount to bill paid by user

Calculate the Bill as per the following tariff : Number of units Rate per unit 1 - 100 units Rs.5.00 101-200 units Rs.7.00 201-300 units Rs.10.00 Above 300 Rs:15.00 Before we write a program to calculate the electricity bill we must understand electricity charges and rates. /*1 - 100 unit - 5/= 101-200 unit - 7/= 201-300 unit - 10/= above 300 - 15/=*/ Explanation if the unit consumed less or equal to 100 units, calculates the total amount of usage =unit*5 if unit consumed between 100 to 200 units, calculates the total amount of usage =(100*5)+(unit-100)*7) if unit consumed between 200 to 300 units ,calculates total amount of usage =(100*5)+(100*7)+(unit-200)*10 if unit consumed above 300 units ,calculates total amount of usage =(100*5)+(100*7)+(100*10)+(unit-300)*15 No additional charge Source code import java.util

Wap to enter a number and Decide whether the number is Buzz number or Not using Java

This program checks if a number entered is a Buzz Number or not in JAVA. A number is said to be Buzz Number if it ends with 7 or is divisible by 7. Example- 21,67,77 import java.util.*; public class Buzz {     public static void main(String args[])     {         Scanner sc=new Scanner(System.in);         System.out.println("Enter the number to be checked.");         int num=sc.nextInt();         if(num%10==7 || num%7==0)         {             System.out.println(num+" is a Buzz Number.");         }         else         {             System.out.println(num+" is not a Buzz Number.");         }     } } Enter the number to be checked. 77 77 is a Buzz Number.

Wap to enter the length and breadth of a rectangle and print area and perimenter

import java.util.*; class Rectangle {         public static void main(String args[])         {             int l,b,ar,p; // local variable             Scanner sc=new Scanner(System.in);             System.out.println("Enter length and breadth");             l=sc.nextInt();             b=sc.nextInt();             ar=l*b;             p=2*(l+b);             System.out.println("Area="+ar);             System.out.println("perimeter="+p);         }     }                 Enter length and breadth 10 20 Area=200 perimeter=60

Wap to enter the side of and print area and perimenter in Java

import java.util.*; class side {     public static void main(String args[])     {         int s,ar,pm; //variable         Scanner sc=new Scanner(System.in);         System.out.println("Enter the side");         s=sc.nextInt();         ar=s*s;         pm=4*s;         System.out.println("Area="+ar);         System.out.println("Perimenter="+pm);     } } Output: Enter the side 10 Area=100 Perimenter=40

Design a class name ShowRoom with the following description: Instance variables/data members: String name: to store the name of the customer. long mobno: to store customer’s mobile number. double cost: to store the cost of the item purchased. double dis: to store the discount amount. double amount: to store the amount to be paid after discount. Methods: ShowRoom(): default constructor to initialize the data members void input(): to input customer name, mobile number, cost void calculate(): to calculate discount on the cost of purchased items, based on the following criteria Cost Discount(In percentage) Less than or equal to ₹ 10000 5 % More than ₹ 10000 and less than or equal to ₹ 20000 10 % More than ₹ 20000 and less than or equal to ₹ 35000 15 % More than ₹ 35000 20% void display()- To display customer, mobile number, amount to be paid after discount. Write a main() method to create an object of the class and call the above methods.

import java . util . Scanner ; class ShowRoom { String name ; long mobno ; double cost , dis , amount ; ShowRoom ( ) //default constructor { name = "" ; mobno = 0L ; cost = 0.0d ; dis = 0.0d ; amount = 0.0d ; } void input ( ) { Scanner kb = new Scanner ( System . in ) ; System . out . print ( "Enter your name: " ) ; name = kb . nextLine ( ) ; System . out . print ( "Enter your Mobile Number: " ) ; mobno = kb . nextLong ( ) ; System . out . print ( "Enter cost of item purchased: " ) ; cost = kb . nextDouble ( ) ; } void calculate ( ) { if ( cost <= 10000 ) { dis = cost * 5 / 100 ; amount = cost - dis ; } else if ( cost > 10000 && cost <= 20000 ) { dis = cost * 10 / 100 ; amount = cost - dis ; } else if ( cost > 20000 && cost <= 35000 ) { dis = c