Q2/ Java Data Types Assignment?
Object [ ] = { “Java”, 1.23F, true, false, 23, ‘a’, ‘b’,
23.4F, 45.6F}; Write the Java Program to sum only the
float variables or any data type.
{
public static void main(String[] args) {
String Object[] = { "Java", "1.23F", "true", "false", "23", "a", "b","23.4F", "45.6F"};
double obj[]={1.23,23.4,45.6};
double sum=obj[0]+obj[1]+obj[2];
System.out.println("Sum of float variables is: "+sum);
}
}
Comments
Leave a comment