Java Programming class Average using String and float data type - IT 111

Another, I have another solution to calculate the Average using String and float for the data type. Which is very simple, organize and short coding. all you have to do is that put another variable along with float data type to call the average to execute it formula. You formula will be separate to your System out print line code. 

The body coding are still the same only Double replace to Float. Just refer the code code below.

Source Code:
import java.util.*;
public class Average
{
 public static void main(String[]args)
 {

  String Sname;
  float prelim, midterm, prefinal, finals, Average;

Scanner in= new Scanner(System.in);
System.out.println("Enter student");
Sname = in.next();
System.out.println("Enter Prelim Grade");
prelim = in.nextFloat();
System.out.println("Enter Midterm Grade");
midterm = in.nextFloat();
System.out.println("Enter Prefinals Grade");
prefinal = in.nextFloat();
System.out.println("Enter Finals Grade");
finals = in.nextFloat();

Average=((prelim+midterm+prefinal+finals)/4);

System.out.println("Student Name:"+Sname+"\n"+"Average is:"+Average);
 }
}

Familiarazation and variable calling and definition is required. I hope it will help you.
Related Posts Plugin for WordPress, Blogger...