0% found this document useful (0 votes)
5 views

Week1 Basic Java Practice Questions

basically its abut java problems

Uploaded by

jhashu23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Week1 Basic Java Practice Questions

basically its abut java problems

Uploaded by

jhashu23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Week1 Basic Java Practice questions – Control Structures

D. JHASHMI
RA2311003011617
Section: G2
1.Even or Odd Number Check
ALGORITHM:

1. Start

2. Prompt the user to enter a number.

3. Read the input number.

4. Convert the input to an integer.

5. Check if the number divided by 2 has a remainder 0.

6. End

PROGRAM:

import java.util.Scanner;

public class Question1 {

public static void main(String[] args) {

int num;

Scanner sc = new Scanner(System.in);

System.out.println("Enter number:");

num = sc.nextInt();

if (num % 2 == 0) {

System.out.println("The number is even");

else{

System.out.println("The number is odd");

}
}
2.Age Verification:
ALGORITHM:
1. Start
2. Prompt the user to enter their age.
3. Read the input age.
4. Convert the input to an integer.
5. Check if the age is 18 or above.
6. End

3.Vending Machine (Single Choice):


ALGORITHM:
1. Start
2. Display a message “Press 1 for juice or 2 for
soda.”
3. Prompt the user to enter their choice.
4. Check the choice.
5. End.

4. Temperature Check:
ALGORITHM :
1. Start
2.
Initialize
the
variables.
3. Read
User
Input.
4. Check Temperature and Print Message.
5. End

5. Positive, Negative, or Zero:


ALGORITHM:
1. Start
2. Initialize the variables.
3. Display Prompt.
4. Read User Input.
5. Check number and print message.
6. End
6.Grading System:
ALGORITHM:
1. Start
2. Initialize the variables.
3. Display Prompt.
4. Read User Input.
5. Determine Grade using Switch Statements.
6. Print the grade.
7. End
7. Simple Calculator:
ALGORITHM:
1. Start
2. Display Prompt for operation choice.
3. Read User Choice.
4. Perform Operation based on Choice.
5. Close the scanner.
6. End
8. Leap Year Check:
ALGORITHM :
1. Start
2. Initialize the variable.
3. Display Prompt.
4. Read user Input.
5. Determine if the Year is a Leap year.
6. End

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy