Share all news to all guy ;)

Enter Slide 1 Title Here

Enter Slide 2 Title Here

Enter Slide 3 Title Here

Showing posts with label Java Language. Show all posts
Showing posts with label Java Language. Show all posts

Monday, December 22, 2014



              Write Java program to print the table of characters that are equivalent to the Ascii codes from 1 to 255. 

Code Here :

 public static void main(String[] args) {
       char Asci=1;
       for(int i=1 ; i<=255 ; i++){
            System.out.print(i+" "+Asci +" ");
            Asci++;
       }
       
    }
    
}




             Write a program that asks the user to type 10 integers and writes the sum of these integers. Using for loop. Total sum of ten integer ( 1+2+3+4+5+6+7+8+9+10=55) .

Code here :

 public static void main(String[] args) {
        int sum=0;
       for(int i=1 ; i<=10 ; i++){
            System.out.print(i + " + ");
            sum = sum +i;
       }
       System.out.print("\b\b\b");
       System.out.println(" = " + sum);
    }
    

}



             Write a program that will ask the user to input three integer values from the keyboard. Then it will print the smallest and largest of those numbers. 

Code Here :

public static void main(String[] args) {
        int Num1, Num2, Num3, Maxi=0, Mini = 0;
        Scanner In = new Scanner(System.in);

        System.out.print("Enter Three Interger Number: ");
        Num1 = In.nextInt();
        Num2 = In.nextInt();
        Num3 = In.nextInt();

        if (Num1 > Num2 && Num1 > Num3 ) 
            Maxi = Num1;
        else if (Num2 > Num1 && Num2 > Num3)
            Maxi = Num2;
        else if (Num3 > Num1 && Num3 > Num2) 
            Maxi = Num3;
        if(Num1 <Num2 && Num1 < Num3)
            Mini = Num1;
        else if (Num2 < Num1 && Num2 < Num3)
            Mini = Num2;
        else if (Num3 < Num1 && Num3 < Num2)
            Mini = Num3;
        
        System.out.println("Maximize Number is: " + Maxi);
        System.out.println("Minimize Number is: " + Mini);
    }
}



               Write a program that will display the calculator menu. The program will prompt the user to choose the operation choice (from 1 to 5). Then it asks the user to input two integer vales for the calculation. See the sample below.

Code Here :

 public static void main(String[] args) {
        int Num1, Num2, op, Result = 0;
        char ch;
        do {
            Scanner In = new Scanner(System.in);
            System.out.println("MAIN MENU");
            System.out.println("1.Add");
            System.out.println("2.Subtract");
            System.out.println("3.Multipy");
            System.out.println("4.Divide");
            System.out.println("5.Mudulus");
            System.out.println(" ");
            System.out.print("Enter Yours Choice: ");
            op = In.nextInt();
            System.out.print("Enter Your Two Number: ");
            Num1 = In.nextInt();
            Num2 = In.nextInt();
            switch (op) {
                case 1:
                    Result = Num1 + Num2;
                    break;
                case 2:
                    Result = Num1 - Num2;
                    break;
                case 3:
                    Result = Num1 * Num2;
                    break;
                case 4:
                    Result = Num1 / Num2;
                    break;
                case 5:
                    Result = Num1 % Num2;
                    break;
                default:
                    System.out.println("You're Enter in Wrong Operator");
            }
            System.out.println("Your Result is: " + Result);
            System.out.println(" ");
            System.out.print("Do you want to calculate agian ? : [Y/N] ");
            ch = In.next().charAt(0);
        }while(ch=='y' || ch=='Y');
        
    }
}

Before You Go : Help Like my Facebook Page :  www.facebook.com/Str168 or on my Web Page . And Help Subscribe my Youtube Channel : https://www.youtube.com/channel/UC79-6IEtqwIwGvDXZCQE-4A/feed?view_as=public For get the news Videos of Key Of IT . Thank You ;)


       Write a program that will ask the user to input n positive numbers. The program will terminate if one of those number is not positive.

Saturday, December 20, 2014




This code is same last post , but it's show Star (pkay) like a picture ;).




    This Code will show you Decreasing Pattern (But It's is a number not *  ).

Here Code :


public static void main(String[] args) {
        for(int i=7 ; i>=1 ;i--)
        {
            for(int j=1 ; j<=i; j++)
                System.out.print(j + " ");
            System.out.println("");
        }
    }
   
}



          This code is show it a picture :)



    About this , it's will find a Maximize of Three Number ;) . The User Need to Input Three Integer and then its will show the Maximize Number :D .

       This Java code is to sum two number , not for sum only and user can use it for Calculator of Two Number ;) . Because it have all operator ..............

public static void main(String[] args) {
        double Num1,Num2,Result=0;
        char op;
       
        Scanner In = new Scanner (System.in);
       
        System.out.print("Enter First Number: ");
        Num1 = In.nextDouble();
       
        System.out.print("Please Choose: ");
        System.out.print("'+','-','*','/','%' : ");
        op = In.next().charAt(0);
       
        System.out.print("Enter Second Number: ");
        Num2 = In.nextDouble();
       
         switch (op) {
            case '+': Result = Num1 + Num2; break;
            case '-': Result = Num1 - Num2; break;
            case '*': Result = Num1 * Num2; break;
            case '/': Result = Num1 / Num2; break;
            default : System.out.printf("Enter Wrong");
        }
        System.out.println("Result: " + Result);
    }
   
}


Here is Java code to find a Grade of Student , we must to input Quiz , Mid Term , and Final Score to see a Result Grade of Student ;) .
You can copy this code to run on your computer :


public static void main(String[] args) {
        double Quiz ,MidTerm,FinalScore,Avg;
        Scanner Output = new Scanner (System.in);
       
        System.out.println("Quiz: ");
        Quiz = Output.nextDouble();
        System.out.println("Mid Term: ");
        MidTerm = Output.nextDouble();
        System.out.println("Final Score: ");
        FinalScore = Output.nextDouble();
       
        Avg = (Quiz + MidTerm + FinalScore);
        System.out.println("Total Average: " + Avg);
       
        if(Avg >=90 && Avg<=100)
            System.out.println("Grade: A");
        else if(Avg >=70 && Avg<90)
            System.out.println("Grade: B");
        else if(Avg >=50 && Avg<70)
            System.out.println("Grade: C");
        else
            System.out.println("GradeF");
               
    }
   
}

Popular Posts

Powered by Blogger.