diff --git a/C/Program-71 b/C/Program-71 deleted file mode 100644 index 2adf2599..00000000 --- a/C/Program-71 +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include -void push(); -void pop(); -void display(); -struct node -{ -int val; -struct node *next; -}; -struct node *head; - -void main () -{ - int choice=0; - printf("\n*********Stack operations using linked list*********\n"); - printf("\n----------------------------------------------\n"); - while(choice != 4) - { - printf("\n\nChose one from the below options...\n"); - printf("\n1.Push\n2.Pop\n3.Show\n4.Exit"); - printf("\n Enter your choice \n"); - scanf("%d",&choice); - switch(choice) - { - case 1: - { - push(); - break; - } - case 2: - { - pop(); - break; - } - case 3: - { - display(); - break; - } - case 4: - { - printf("Exiting...."); - break; - } - default: - { - printf("Please Enter valid choice "); - } - }; -} -} -//adding a node -void push () -{ - int val; - struct node *ptr = (struct node*)malloc(sizeof(struct node)); - if(ptr == NULL) - { - printf("not able to push the element"); - } - else - { - printf("Enter the value"); - scanf("%d",&val); - if(head==NULL) - { - ptr->val = val; - ptr -> next = NULL; - head=ptr; - } - else - { - ptr->val = val; - ptr->next = head; - head=ptr; - - } - printf("Item pushed"); - - } -} -// deleting a node -void pop() -{ - int item; - struct node *ptr; - if (head == NULL) - { - printf("Underflow"); - } - else - { - item = head->val; - ptr = head; - head = head->next; - free(ptr); - printf("Item popped"); - - } -} -//display node transversal -void display() -{ - int i; - struct node *ptr; - ptr=head; - if(ptr == NULL) - { - printf("Stack is empty\n"); - } - else - { - printf("Printing Stack elements \n"); - while(ptr!=NULL) - { - printf("%d\n",ptr->val); - ptr = ptr->next; - } - } -} diff --git a/C/Program-72 b/C/Program-72 deleted file mode 100644 index 58a9ca9f..00000000 --- a/C/Program-72 +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include - -#define SIZE 10 - -void push(int); -void pop(); -void display(); - -int stack[SIZE], top = -1; - -void main() -{ - int value, choice; - clrscr(); - while(1){ - printf("\n\n***** MENU *****\n"); - printf("1. Push\n2. Pop\n3. Display\n4. Exit"); - printf("\nEnter your choice: "); - scanf("%d",&choice); - switch(choice){ - case 1: printf("Enter the value to be insert: "); - scanf("%d",&value); - push(value); - break; - case 2: pop(); - break; - case 3: display(); - break; - case 4: exit(0); - default: printf("\nWrong selection!!! Try again!!!"); - } - } -} -//adding a top stack using array index -void push(int value){ - if(top == SIZE-1) - printf("\nStack is Full!!! Insertion is not possible!!!"); - else{ - top++; - stack[top] = value; - printf("\nInsertion success!!!"); - } -} -//deleting a stack top usin array index -void pop(){ - if(top == -1) - printf("\nStack is Empty!!! Deletion is not possible!!!"); - else{ - printf("\nDeleted : %d", stack[top]); - top--; - } -} -//display stack transversal using array index iteration -void display(){ - if(top == -1) - printf("\nStack is Empty!!!"); - else{ - int i; - printf("\nStack elements are:\n"); - for(i=top; i>=0; i--) - printf("%d\n",stack[i]); - } -} diff --git a/Java/Program-11/Program.java b/Java/Program-11/Program.java new file mode 100644 index 00000000..1d293511 --- /dev/null +++ b/Java/Program-11/Program.java @@ -0,0 +1,18 @@ +// Java program to find compound interest for +// given values. +import java.io.*; + +class GFG +{ + public static void main(String args[]) + { + double principle = 10000, rate = 10.25, time = 5; + + /* Calculate compound interest */ + double CI = principle * + (Math.pow((1 + rate / 100), time)); + + System.out.println("Compound Interest is "+ CI); + } +} +// This code is contributed by Anant Agarwal. diff --git a/Java/Program-11/Readme.md b/Java/Program-11/Readme.md new file mode 100644 index 00000000..99c44d71 --- /dev/null +++ b/Java/Program-11/Readme.md @@ -0,0 +1,16 @@ +Q. Java Program for compound interest + + +Formula to calculate compound interest annually is given by: + +Compound Interest = P(1 + R/100)r +Where, +P is principle amount +R is the rate and +T is the time span + + +Input : Principle (amount): 1200 + Time: 2 + Rate: 5.4 +Output : Compound Interest = 1333.099243 \ No newline at end of file diff --git a/Java/program-10/Program.java b/Java/program-10/Program.java new file mode 100644 index 00000000..7a60ae5c --- /dev/null +++ b/Java/program-10/Program.java @@ -0,0 +1,19 @@ +// A Simple JAVA program to compute +// simple interest for given principal +// amount, time and rate of interest. +import java.io.*; + +class GFG { + public static void main(String args[]) + { + // We can change values here for + // different inputs + float P = 1, R = 1, T = 1; + + /* Calculate simple interest */ + float SI = (P * T * R) / 100; + System.out.println("Simple interest = " + SI); + } +} + +// This code is contributed by Anant Agarwal. diff --git a/Java/program-10/Readme.md b/Java/program-10/Readme.md new file mode 100644 index 00000000..f8db2c4d --- /dev/null +++ b/Java/program-10/Readme.md @@ -0,0 +1,24 @@ +Q. Java Program for simple interest + +Simple interest formula is given by: +Simple Interest = (P x T x R)/100 +Where, +P is the principle amount +T is the time and +R is the rate + + +EXAMPLE1: +Input : P = 10000 + R = 5 + T = 5 +Output :2500 +We need to find simple interest on +Rs. 10, 000 at the rate of 5% for 5 +units of time. + +EXAMPLE2: +Input : P = 3000 + R = 7 + T = 1 +Output :210 diff --git a/Java/program-9/README.md.txt b/Java/program-9/Readme.md similarity index 100% rename from Java/program-9/README.md.txt rename to Java/program-9/Readme.md diff --git a/Program-72 b/Program-72 deleted file mode 100644 index 6c075b7c..00000000 --- a/Program-72 +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include - -#define SIZE 10 - -void push(int); -void pop(); -void display(); - -int stack[SIZE], top = -1; - -void main() -{ - int value, choice; - clrscr(); - while(1){ - printf("\n\n***** MENU *****\n"); - printf("1. Push\n2. Pop\n3. Display\n4. Exit"); - printf("\nEnter your choice: "); - scanf("%d",&choice); - switch(choice){ - case 1: printf("Enter the value to be insert: "); - scanf("%d",&value); - push(value); - break; - case 2: pop(); - break; - case 3: display(); - break; - case 4: exit(0); - default: printf("\nWrong selection!!! Try again!!!"); - } - } -} -//adding a top stack using array index -void push(int value){ - if(top == SIZE-1) - printf("\nStack is Full!!! Insertion is not possible!!!"); - else{ - top++; - stack[top] = value; - printf("\nInsertion success!!!"); - } -} -//deleting a stack top usin array index -void pop(){ - if(top == -1) - printf("\nStack is Empty!!! Deletion is not possible!!!"); - else{ - printf("\nDeleted : %d", stack[top]); - top--; - } -} -//display stack transversal using array index iteration -void display(){ - if(top == -1) - printf("\nStack is Empty!!!"); - else{ - int i; - printf("\nStack elements are:\n"); - for(i=top; i>=0; i--) - printf("%d\n",stack[i]); - } -} -