A simple program to use variable & Datatype
https://wordpress-343193-1101484.cloudwaysapps.com/data-type
To learn more about variables and datatype click the given link.
Write a program to declare and initialize some variables of int, string and double , accept their values and print the result according the requirement.
public class Variables
{
public static void main()
{
//declaration of variables
String st_nm;
int std;
double total;
int roll_no;
int math;
int geo;
int comp;
int bio;
int hin;
//initialization of variables with the values
st_nm="Dhvani";
std=12;
roll_no=1201;
math=98;
geo=100;
comp=99;
bio=97;
hin=90;
total=math+geo+comp+bio+hin;
System.out.println("The total marks of”+ st_nm+” is "+total);
double average=total/5;
System.out.println("The average of ”+ st_nm +” is "+average);
double per=total*100/500;
System.out.println("The percentage of”+ st_nm +” is "+per);
}
}Output:
The total marks of Dhvani is 484.0
The average of Dhvani is 96.8
The percentage of Dhvani is 96.8
To learn more about taking input using scanner class watch the video
https://youtu.be/GeSDLXhzFig
Related Posts
Continue learning with these related articles

User-Defined Methods in Java for ICSE Class 10: Parameters, Return and Overloading
ICSE Class 10 Computer Applications notes on user-defined methods: method prototype and signature, formal and actual parameters, return types, call by value vs call by reference, pure and impure methods, static methods and method overloading, with programs.

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.