Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package switchcase;
- import java.util.Scanner;
- /**
- *
- * @author pclab
- */
- public class q3 {
- public static void main(String[] args){
- Scanner keyboard=new Scanner(System.in);
- int no1, no2;
- System.out.println("Input integer: ");
- no1=keyboard.nextInt();
- if (no1%2==1)
- {
- no2=(no1*2)-3;
- System.out.println("The answer is "+no2);
- }
- else
- if(no1%2==0)
- {
- no2=(no1*3)-5;
- System.out.println("The answer is "+no2);
- }
- else
- System.out.println("Invalid input");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement