Skip to main content

Posts

Get Even Numbers Using Java Stream API

Java Stream API — Even Numbers (Full Screen) Java Stream API — Get Even Numbers Example 1 — Filter even numbers from a list Creates a list, uses Stream to filter evens, and prints them. Copy import java.util.*; import java.util.stream.*; public class EvenNumbersStream { public static void main(String[] args) { // Create a list of numbers List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // Use Stream API to filter even numbers List<Integer> evenNumbers = numbers.stream() .filter(n -> n % 2 == 0) .collect(Collectors.toList()); // Print the even numbers System.out.println( "Even numbers: " + evenNumbers); } } Example 2 — Use IntStream.rangeClosed ...

Calculate Gross Salary

input: Basic Salary,DA and HRA (i.e. 6000,250,500 etc.) output: The Gross Salary will be printed on the screen. CODE----> #include<stdio.h> #include<conio.h> main() {        float basic, hra, da, pf, gross;        printf (" Enter Basic Salary : ");        scanf (" %f ",&basic);        printf (" \nEnter HRA : ");        scanf (" %f ",&hra);        printf (" \nEnter D.A. : ");        scanf (" %f ",&da);        /*pf = 10%*/        pf= (basic*10)/100;        printf ("\nPF = %f ",pf);        gross=basic+da+hra+pf;        printf ("\n\nGross Salary : %f ",gr...

Sum of two Integer numbers using function

In this C program we will calculate the summation of two numbers(int) using "Function" and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers(int). (i.e. 15,23 etc.) output: Summation of the given numbers(int) will be printed on the screen. CODE----> #include<stdio.h> #include<conio.h> #include<stdlib.h> int sum();     /* function declaration */ main()     /* main function */ {       int choice;       printf (" **********WELCOME**********\n\n ");       printf (" Please, select your choice.\n ");       printf (" 1.Addition(press 1, for addition)\n2.Exit(press 2,for quit)\n\n ");       printf (" Please, Enter your choice : ");       scanf (" %d ",&choice);       if( cho...

OR Gate

OR Gate Introduction :- The OR Gate performs logical addition, commonly known as OR function. The OR Gate has two or more inputs and only one output. The operation of OR Gate is such that a HIGH (1) on the output is produced when any of the input is HIGH (1). The output is LOW (0) only when all the inputs are LOW (0). Logic Expression :- If A and B are the input variables of an OR Gate and Y is it's output, then, Y = A + B Truth-Table :- Truth-Table of OR Gate Logic Symbol of 2-input OR Gate :- Logical symbol of 2-input OR Gate OR Gate's IC-base diagram :- OR-Gate's IC-base diagram Apparatus :- Bread-board, LED-light, Battery(Power-Supply), IC-7432, Multimeter and Resistance. Procedure :-      1. Verify whether all the wires and components are in good condition.      2. Set-...

Multiplication of two Float numbers in C++ Language without and with Class

In this C++ program we will calculate the multiplication of two numbers(float) and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers(float). (i.e. 15.4,2.4 etc.) output: Multiplication of the given numbers(float) will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { float num1,num2,mul; cout << " \n      Enter a Number : " ; cin >>num1; cout << "\n      Enter another Number : " ; cin >>num2; mul=num1*num2; cout << "\n      The multiplication of the Numbers is : " << mul << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class multi { private : float x , y ; public : void get () { cout << "Enter two num...

Difference between two numbers(float) in C++ Language without and with Class

In this C++ program we will calculate the difference between the two numbers(float) and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15.6,65.7 etc.) output: Difference between the given numbers(float) will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { float num1, num2, difference; cout << " \n Enter a Number : " ; cin >>num1 ; cout << " \n Enter another Number : " ; cin >>num2 ; difference = num1 - num2 ; cout \n The Difference between the Numbers is : " <<difference <<endl ; system (" pause ") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class differ { private : float x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x ...

Sum of two float numbers in C++ without and with Class

In this C++ program we will calculate the sum of the two numbers(float) and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15.6,65.7 etc.) output: Sum of the given numbers(float) will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { float a,b,sum; cout << " \n Enter a Number : " ; cin >>a; cout << " \n Enter another Number : " ; cin >>b; sum=a+b; cout \n The sum of the Numbers is : " <<sum <<endl ; system (" pause ") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class sum { private : float x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp () { float c ; c = x + y ; cout << ...

Float division in C++ without and with Class

In this C++ program we will calculate the division between two numbers(float). The numbers will be taken from the user. input: Two numbers.(i.e : 9,56,548) output: After division the result will be printed on the screen. CODE----> #include<iostream> using namespace std; main() {    float num1, num2, div;    cout <<"       Please, Enter a Number  :  ";    cin >>num1;    cout <<" \n      Please, Enter another Number :  ";    cin >>num2;   div=num1/num2;    cout \n      The result is :  " <<div  <<" \n ";   system (" pause "); } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class div { private : float x , y ; public : void get () { cout <...