plz solve plzzzzzzzz solve questionnn numberrr 5,7 and 8 using only if...else if..
pleasee
java program
only use
if....else if
only plzz
Answers
Answer:
5)
import java.util.Scanner; class GetInputData { public static void main(String args[]) { int num; float fnum; String str; Scanner in = new Scanner(System.in); //Get input String System.out.println("Enter a string: "); str = in.nextLine(); System.out.println("Input String is: "+str); //Get input Integer System.out.println("Enter an integer: "); num = in.nextInt(); System.out.println("Input Integer is: "+num); //Get input float number System.out.println("Enter a float number: "); fnum = in.nextFloat(); System.out.println("Input Float number is: "+fnum); } }
Output:
Enter a string: Chaitanya Input String is: Chaitanya Enter an integer: 27 Input Integer is: 27 Enter a float number: 12.56 Input Float number is: 12.56
float number will be 12.56 enter 7