Monday, April 3, 2017

Learn Programming by Coding.

1. Write a functions add/sub/multiply/divide which will take two numbers and perform these operations.
2.  Make the program 1 menu driven. There should following options:
                 Menu:
                            1. Add
                            2. Substract
                            3. Multiply
                            4. Divide
                            5. Exit
3.a Write a function which will take a number and print all it's factors.
3.b Write a function which will take a number and instead of printing return all it's factors.
4.  Implement your own arrayList class and implement the following functions:
     a.    add(int num)  //this function will take input number and add it to your arraylist.
     b.    add(int num,  int position)  //this function will take input number and it to the given position.
     c.    clear()  //this function will delete all the elements from the array.
    d.     length()  //this function will return the number of elements in the array.
    e.     is_empty()  //this function will return true if there is no element in the array or else return false.
   f.       index_of(int num)  //this function should return the index of num from the array. If the number is not present in the array then return -1.    

1 comment:

Unknown said...

package hashmapdemo;
import java.util.Scanner;
public class Operations {
public static void main(String[] args){
Scanner np = new Scanner(System.in);
System.out.println("Enter the no x");
int x = np.nextInt();
System.out.println("Enter the no y");
int y = np.nextInt();
int z = x+y;
int d = x/y;
int m = x*y;
int s = x-y;

System.out.println("sum of " +x+ "And" +y+ "is:" +z);
System.out.println("Division of " +x+ "And" +y+ "is:" +d);
System.out.println("Multiply of " +x+ "And" +y+ "is:" +m);
System.out.println("Subtraction of " +x+ "And" +y+ "is:" +s);





}






}