Suppose that the input is:
58 23 46 75 98 150 12 176 145 -999
What is the output of the following program?
import java.util.*;
public class FindTheOutput
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
int num;
num = console.nextInt();
while (num != -999)
{
System.out.print(num % 25 + " ");
num = console.nextInt();
}
System.out.println();
}
}
1.List some reasons why it is worthwhile to study assembly language programming.
2. Section 15.4 includes a C program that calculates the greatest common divisor of two integers. Describe the algorithm in words and show how the program does implement the Euclid algorithm approach to calculating the greatest common divisor.
⦁ Write the algorithm for the convex hull problem using the divide and conquer technique and its time complexity.
Create a class called employee with the following details as variables within it.
1. Name of the employee
2. Age
3. Designation
4. Salary
Get the details of 5 employees and initialize it using Constructor. Release resources using destructor. print the name, designation and salary of employees, Find the highest salaried employee in professor grade and display their details.
(Initialize the class members using constructors and destroy the objects by using destructor)
Runtime Input :
Sri Ram 32 Prof. 70000
Skathi 31 Prof. 50000
Sanjay 29 AP 39050
Shiva 27 AP 37200
Guna 17 AP 25150
Output :
Employee Details:
Sri Ram Prof. 70000
Skathi ASP 50000
Sanjay AP 39050
Shiva AP 37200
Guna AP 25150
Highest Salaried Employee:
Sri Ram 32 Prof. 70000
Suppose you are given n sets:S1,S2.....Sn each set is having n elements.the problems is to find whether some pairs of these sets are disjoint,i.e. there are no common elements in these sets.write pseudo code and calculate its time complexity.
Correct the program so that it works properly.
import java.util.*;
public class Main {
static Scanner console = new Scanner(System.in);
public static void main(String[] args) {
char response;
double num1;
double num2;
System.out.println("This program adds two numbers.");
System.out.print("Would you like to run the program: (Y/y) ");
response = console.next().charAt(0);
System.out.println();
while (response == 'Y' && response == 'y')
{
System.out.print("Enter two numbers: ");
num1 = console.nextInt();
num2 = console.nextInt();
System.out.println();
System.out.printf("%.2f + %.2f = %.2f %n", num1, num2, (num1 - num2));
System.out.print("Would you like to add again: (Y/y) ");
response = console.next().charAt(0);
System.out.println();
}
}
}
Suppose that the input is:
38 35 71 14 -1
What is the output of the following code? Assume all variables are properly declared.
sum = 0;
num = console.nextInt();
while (num != -1)
{
sum = sum + num;
num = console.nextInt();
}
System.out.println("Sum = " + sum);
Write and run a visual payroll program for 10 employee of a company.The gross pay sums the basic pay, housing allowance and professional allowance (where applicable).Workers grade levels range from 1to 16. Housing allowance of workers is 30% of basic pay for workers on levels 8 to 16 and 40% for levels 1-7 workers.Transport allowance is 20% of basic pay for all workers. Hazard allowance is 15% of basic pay for only levels 8-16 workers. The net pay, which is the take home pay is the gross pay tax (10% of gross pay). Designs form through which each workers data can be entered
Numbers in String - 2
Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
35
17.5
Sample Input 2
Tech Foundation 35567
Sample Output 2
35567
35567.0
sample input 3
1time3 %times4
sample output 3
8
2.67