Write the definition of a void method that takes as input


Q1: Write the definition of a void method that takes as input two parameters of type int, say sum and testScore. The method updates the value of sum by adding the value of testScore. The new value of sum is sent back to the caller statement.

Q2: Write a method, is Vowel, which returns the value true if a given character is a vowel and otherwise returns false.

Q3: Write the definition of a void method that inputs an integer number and output the result as 3 times the value of that number.

Q4: Find the sum of the following series using methods:

(a) 1+1/2+1/3+1/4+1/5

(b) 1-2+5-10+17-26

Q5. Write the definition of a method that takes as input a char value and returns true if the character is uppercase, otherwise, it returns false.

Q6. Create a class that mimics a Bank account. It should have functions to get the account balance, withdraw money, should not allow for overdraft i.e., should check that minimum balance is zero. It should show the account holders name, bank and account details. The main() function should be used to display and check all functions.

Q7. Create a program to mimic a petrol vending machine. It should be able to sell petrol and diesel at Rs 65 per litre and Rs 45 per litre. The program should take as input the total amount of petrol/diesel to be sold and produce a bill with 12% Vat and 6% sales tax.

Q8. Create a program that takes marks in five subjects English, Hindi, Maths, Science, Social Studies as input. It calculates grades and displays it as follows:

  • Marks >= 90 = Grade A+
  • Marks >= 75 = Grade A
  • Marks >= 60 = Grade B
  • Marks >= 50 = Grade C
  • Marks >= 40 = Grade D
  • Marks <40 = Grade D

If the overall marks are less than 200 or grades in 2 or more subjects is F. then the child is held back else he is promoted.

Q9. Write a program in lava to accept two numbers and check whether they are twin prime or not by using the function name prime (). The function returns 1 if the number is prime otherwise returns 0.

Twin Prime numbers are such prime numbers whose difference is 2, (11, 31), (17, 19)........ are the example of twin prime numbers.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write the definition of a void method that takes as input
Reference No:- TGS01514349

Now Priced at $30 (50% Discount)

Recommended (97%)

Rated (4.9/5)