Skip to content

Java programming #6166

@Simadebi

Description

@Simadebi

What would you like to Propose?

//1.solve the bellow problem as taking input from user
package studentdetalis;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
//datatype variable declear
String studentName;
int studentID,studentAge;
float studentFee;
char studentGrade;
//taking student data as input
System.out.print("enter any student Name= ");
studentName=input.nextLine();
System.out.print("enter any student ID= ");
studentID=input.nextInt();
System.out.print("enter any student age=");
studentAge=input.nextInt();
System.out.print("enter any student fee=");
studentFee=input.nextFloat();
System.out.print("enter any student grade=");
studentGrade=input.next().charAt(0);
//print student detalis
System.out.println("Student name="+studentName);
System.out.println("Student ID="+studentID);
System.out.println("Student age="+studentAge);
System.out.println("Student Fee="+studentFee);
System.out.println("Student grade="+studentGrade);
}
}

Issue details

//2.sum of two numbers
package labtask3;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
//data type variable declear
int sum=0,num,temp,r;
System.out.print("enter any two numbers= ");
//take as user iput
num=input.nextInt();
temp=num;
while(temp!=0) {
r=temp%10;
sum=sum+r;
temp=temp/10;
}
//print variabls
System.out.println("Sum of digits= "+sum);

}

}

Additional Information

//cheak if a number is even or odd
package labtask3;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
//data type variable declear
int num;
System.out.print("enter any number= ");
num=input.nextInt();
if(num%2==0) {
System.out.println("Even");
}
else {
System.out.println("Odd");
}

}

}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions