Assignments

All These Are assignments i want solution from your side.i will publish your sloutions

1.     Prompt the user to provide two numeric values. Using conditional operator to find the smaller & print.
2.     Write a program to generate five random numbers between 50 & 100. Make sure nos. shouldn’t contain decimal point.
3.     Write a program to display a greet message according to the marks obtained by the student. Make use of switch statement.
4.     Write a program to check if a given no. is  prime.
5.     Write a program to display first 5 Armstrong nos.
6.     Write a program to find factorial of a given no.
7.     Write a program to print the Fibonacci series.
8.     Write a program to accept a character from the user. If the letter input is any Vowel then display a message “You have input,Vowel” else display “This is not a Vowel”.
9.     Write a program to store bill number, name, quantity and price of item .Take values from the user and display the total bill amount.



Assignment-2






1) Print the following on console.
  3 2 1
       +      4 5
-------
3 6 6


2) Write an application that calculates the squares and cubes of the numbers from 0 to 10 and prints the resulting values in table format, as follows
             Number  Square  Cube
0 0 0
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000       


3) A palindrome is a number or a text phrase that reads the same backwards as forwards. For example, each of the following five-digit integers are palindromes: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits, display an error message dialog indicating the problem to the user. When the user dismisses the error dialog, allow the user to enter a new value.














4.   Draw the following shapes using C#:


* *     *      *      *     *
*    * *    *      *    *
*    *    * *    *    *
*    *      *    * *    *
*     *      *      *     * *






                            A
                                       AB
   ABC
                           ABCD
                           ABCDE






5. Write an application that reads a nonnegative integer  and computes and prints its factorial.


6. Enter basic salary from the user. Write a program to calculate DA and HRA on the following conditions:












Salary DA HRA
<=2000 10% 20%


>2000 && <=5000 20% 30%
>5000 && <=10000 30% 40%
>10000 50% 50%


7. Write an application that estimates the value of the mathematical constant e by using the formula


1 1       1       1
E= ---  +  ---  +  --- +  --- ……
1!       2!       3!     4!


8. Write a program that prints the following diamond shape. You may use output statements that print a single asterisk (*), a single space or a single newline character.


                                                 *
        *  *  *
                                         *  *  *  *  *
                                     *  *  *  *  *  *  *
                                         *  *  *  *  *  
                                             *  *  *
                                                 *
9. Write a program that will accept UserID (robert) and Password (hello) from user and if UserID and Password matches display the information about Robert and if UserID and Password does not matches it should display message “Invalid ID or Password”.


10.  WAP that create a structure as person with three fields First name, Last name , age and a parametric constructor to accept the values from users. Display the output.




11. Write an application that reads a string and determines whether it is a palindrome.





3 comments:

  1. Leave your answers in comments section and your name

    ReplyDelete
  2. 1) Prompt the user to provide two numeric values. Using conditional operator to find the smaller & print.

    var n1 = prompt("type number 1", "Type your number here");
    var n2 = prompt("type number 2", "Type your number here");

    n1 = parseInt(n1);
    n2 = parseInt(n2);
    if (n1 > n2)
    {
    alert("1st number is greater then 2nd");
    }
    else
    {
    alert("2nd number is greater then 1st");
    }



    2) Write a program to generate five random numbers between 50 & 100. Make sure nos. shouldn’t contain decimal point.


    public class GenerateDecimalRandomNumbers
    {
    public static void main(String[] args)
    {

    System.out.println("Random numbers between 1.0 and 100.0 are,");

    for(int i=0; i < 5 ; i++)
    System.out.println("Random Number " + (50 + (Math.random() * (100 - 50))));

    }
    }

    ReplyDelete
  3. 4) Write a program to check if a given no. is prime

    class Prime
    {
    public static void main(String[] args)
    {
    int num = 11;
    int i;
    for (i=2; i < num ;i++ )
    {
    int n = num%i;
    if (n==0)
    {
    System.out.println("not Prime");
    break;
    }
    }
    if(i == num)
    {
    System.out.println("Prime number!");
    }
    }
    }

    5) Write a program to display first 5 Armstrong nos

    import java.util.Scanner;

    class armstrong
    {
    public static void main(String[] args)
    {

    try{

    System.out.println("Enter Number 1");
    Scanner sc = new Scanner(System.in);
    int number1 = sc.nextInt();

    System.out.println("Enter Number 2");
    sc = new Scanner(System.in);
    int number2 = sc.nextInt();

    System.out.println("Armstrong Numbers between "+ number1 + " and " + number2);

    int n=0;

    for (int j=number1 ; j<=number2 ; j++)
    {
    int sum=0;
    int d=0;
    n=j;
    while (n>0)
    {
    d= n%10;
    sum=sum+d*d*d;
    n=n/10;

    }

    if (sum==j)
    {

    System.out.println(j +" ");
    }
    }
    }
    catch (Exception e)
    {
    System.out.println("Error");
    }
    }
    }



    Output :
    --------

    Enter Number 1
    1
    Enter Number 2
    2000
    Armstrong Numbers between 1 and 2000
    1
    153
    370
    371
    407

    6) Write a program to find factorial of a given no.

    class Factorial
    {
    public static void main(String[] args)
    {
    try
    {
    BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("enter the number");
    int a= Integer.parseInt(object.readLine());
    int fact= 1;
    System.out.println("Factorial of " +a+ ":");
    for (int i= 1; i<=a; i++){
    fact=fact*i;
    }
    System.out.println(fact);
    }
    catch (Exception e){}
    }
    }


    7. Write a program to print the Fibonacci series.

    Write a program to print the Fibonacci series.

    class Fibonacci
    {
    public static void main(String[] args)
    {

    int a = 0;
    int b = 1;

    for (int i = 0; i < N; ++i)
    {
    System.out.println(a);
    int temp = b;
    b += a;
    a = temp;
    }
    }
    }

    Now all remaining program m not going to solve bcz they are very easy and it vl be also insult for me :P :P (hihihi)

    All the best
    Priyanka Anand

    ReplyDelete

Your comment is pending for approval

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...