0% found this document useful (0 votes)
41 views1 page

Java Scanner Code

This Java code uses Scanner to input student data including ID, name, gender, marks in 3 subjects, and active status. It calculates the total marks in double and float, and prints the results and input data in single and multiple lines.

Uploaded by

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

Java Scanner Code

This Java code uses Scanner to input student data including ID, name, gender, marks in 3 subjects, and active status. It calculates the total marks in double and float, and prints the results and input data in single and multiple lines.

Uploaded by

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

import java.util.

Scanner;

public class Main


{
public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

int id=sc.nextInt();
sc.nextLine();
String name=sc.nextLine();
char gender=sc.next().charAt(0);
float marks1=sc.nextFloat();
float marks2=sc.nextFloat();
float marks3=sc.nextFloat();
boolean active=sc.nextBoolean();
double result=marks1+marks2+marks3;
float result1=marks1+marks2+marks3;

System.out.println("Totalresult in double :"+result);

System.out.println("Totalresult in float :"+result1);

//Display all the values in single LinkageError

System.out.println(id+" "+name+" "+gender+" "+active+" "+result);

//Display all the values in different lines

System.out.println(id+"\n "+name+"\n "+gender+"\n "+active+"\n "+result);

}
}

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