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();
}
}
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);
1) Create a class named 'Member' having the following members:
Data members
1 - Name
2 - Age
3 - Phone number
4 - Address 5 - Salary
It also has a method named 'printSalary' which prints the salary of the members. Two classes 'Employee' and 'Manager' inherits the 'Member' class. The 'Employee' and 'Manager' classes have data members 'specialization' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a manager by making an object of both of these classes and print the value you assigned.
Write a program that asks the user to enter an account number as a string. The account number consists of 8
characters and is divided as follows:
The first 2 characters are digits and represent the branch (00 for Beirut, 01 for Saida, 02 for Tripoli).
The remaining 6 characters represent the customer’s account number
A valid account number consists of exactly 8 characters. If the account is valid, the program prints the details
(branch and account number). If the account is not valid, the program displays a message to the user.
Given list of students’ records. Write a program with signature as below:
Method Name: getStudentsWithMarksMoreThan()
Input: marks – Integer
Output: List of Students having marks more than input
Also add Unit Test case – both positive and negative.(Any high level language like – Java,
Python, PHP, C#, JavaScript)
Create an applet which take a number as input and display whether it is prime number or not. Use appropriate components, layout and formatting in your program in JAVA.
Write the pseudocode for an application that will:
a) Prompt a user for three numbers.
b) Store the values entered by a user in an array as they are provided by the user.
c) Ask a user if they would like to search for a value:
If the user wishes to search for a value, the user needs to be prompted for a value to search for. If the value is found, a notification needs to be provided to the user.
d) Use a for loop to cycle through the arrays to calculate and display the total of the values stored in the array
the logical structure in which one instruction occurs after another with no branching in java