Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Java Code please Input The first line contains an integer which is either 1 or 2. If it is a 1, it means to create a Date via the default constructor. If it is a 2, 3 integers follow in the next line representing the day, month, and year of the Date to be created. This is then followed by a number m representing the number of operations to be performed followed by the operations themselves as specified below: 1 - setDay 2 - setMonth 3 - setYear 4 - setDate 5 - getDay 6 - getMonth 7 - getYear 8 - toString 9 - dayOfTheWeek For operations 1, 2, 3, one integer follows. For setDate, 3 integers follow (D M Y). For the rest of the operations, no other inputs follow.


Create a simple calculator application in Java which will perform four basic



arithmetic operations (plus, minus, multiplication and division) on a pair of



numbers (input from user) from 0 – 9, except division by zero. It means, this



program will perform arithmetic operations between single digits only, but the



result can be more than one digit and in decimals, obviously. Sample output is



given below:



Enter first number between 0 and 9: 6



Enter second number between 0 and 9: 4



Applying arithmetic operations:



Adding 6 and 4 results = 10



Subtracting 4 from 6 results = 2



Multiplying 6 with 4 results = 24



Dividing 6 by 4 results = 1.5

Write a Class FeeCalculator that’s programed against FeeStructure (or uses FeeStructure Interface) having the following members

Fields: feeStructure

Constructor (using dependency injection -> constructor injection)

Methods:

  • ·   double calculate(int creditHour, String type )
  • ·  double calculate(int creditHour, String type, int discount )

Write two complete classes (FeeStructur2020 & FreeStructur2021) that implements FeeStructure interface

Suppose:

FeeStructure2020 calculates the fee based on the following

  • · PKR 4,100 per creditHour when type is set to “theory”
  • · PKR 12,250 per creditHour when type is set to “lab”

FeeStructure2021 calculates the fee based on the following

  • ·  PKR 4,600 per creditHour when type is set to “theory”
  • ·  PKR 13,750 per creditHour when type is set to “lab”

Write an Interface  FeeStructure that provide the following functionality for calculating Fee Structure

  1.    double calculateFee(int creditHour, String type )
  2.    double calculateFee(int creditHour, String type, int discountPercent )

Write a program to take two numbers as input then display their total using java.io. package for input i.e. InputStreamReader isr= new InputStreamReader(System.in);

BufferedReader br=new BufferedReader(isr);

Integer.parseInt(br.readLine());

Use void only once in public static void main(String args[])

Don't use void second time.


Write a program to take a String as input then display the word which has highest number of vowels.

For example:

Enter a String

EDUCATION IS important

EDUCATION has highest number of vowels

2nd e.g.

Enter a String

Hello use dog

Hello and use has same highest number of vowels


Write a program to take a String as input then display only palindrome words found in the String and also display how many palindrome words found.

For example:

Enter a String

MOM AND dad are talking

Palindrome words: MOM dad

No. of such words: 2


for(i=s.length()-1;i>=0;i--)

{

c=s.charAt(i);

rev=rev+c;

} //To check palindrome words


Create a class Author whose attributes are: name, email, gender and books. Author constructor initializes the values


of name, email, gender and books. Define a static variable, method and block, and use this keyword in your code.

A program is required for a computer game. The user keys in the number of rounds he wishes to play.


For each round the user enters his lucky number. The program takes the number and divides it with a


secret number. If the remainder of the division is zero, it is considered a draw for the round and the total


score is incriminated by 1. Otherwise if it is any other even number, it is considered a win for the round


and the total score is incremented by 3. However if it is an odd number, it is considered a loss for the


round and the total score is decremented by 3. This is done until he completes his rounds. He wins if the


total score at the end is a positive number. Write a Java program to accomplish this.



LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS