Professional Documents
Culture Documents
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
double firstGrade=0;
double secondGrade=0;
double thirdGrade=0;
double average=0;
try{
firstGrade=Double.parseDouble(JOptionPane.showInputDialog("First Grade"));
secondGrade=Double.parseDouble(JOptionPane.showInputDialog("Second Grade"));
thirdGrade=Double.parseDouble(JOptionPane.showInputDialog("Third Grade"));
}catch(Exception e){
JOptionPane.showMessageDialog(null,e.getMessage());
JOptionPane.showMessageDialog(null, "Input is Invalid");
System.exit(0);
}
average=(firstGrade+secondGrade+thirdGrade)/3;
if(average>=60)
{
JOptionPane.showMessageDialog(null,"Average"+average+";-)");
}
else
{
JOptionPane.showMessageDialog(null,"Average"+average+";-(");
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package grades1;
/**
*
* @author AMA
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package grades1;
/**
*
* @author AMA
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import javax.swing.JOptionPane;
public class Grades1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
BufferedReader convert = new BufferedReader (new InputStreamReader (System.in));
double firstGrade=0;
double secondGrade=0;
double thirdGrade=0;
double average=0;
try{
System.out.println("Enter Num1:");
firstGrade=Double.parseDouble(convert.readLine());
System.out.println("Enter Num2:");
secondGrade=Double.parseDouble(convert.readLine());
System.out.println("Enter Num3:");
thirdGrade=Double.parseDouble(convert.readLine());
}catch(Exception e){
System.out.println ("Input is invalid");
System.exit(0);
}
average=(firstGrade+secondGrade+thirdGrade)/3;
if(average>=60)
{
System.out.println ("Average"+average+";-)");
JOptionPane.showMessageDialog(null,"Average"+average+";-)");
}
else
{
System.out.println ("Average"+average+";-(");
JOptionPane.showMessageDialog(null,"Average"+average+";-(");
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mp2;
import java.io.IOException;
import java.util.Scanner;
/**
*
* @author AMA
*/
public class MP2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int num1=0, num2=0, num3=0;
Scanner mp = new Scanner (System.in);
System.out.println("Enter Num1:");
num1=mp.nextInt();
System.out.println("Enter Num2:");
num2=mp.nextInt();
System.out.println("Enter Num3:");
num3=mp.nextInt();
}
}
int num = 1;
*while (num<=5)
{
System.out.print(num);
num++;
}
for (int ctr=1; ctr<=5; ctr++) {
System.out.print(ctr);
}
import java.util.Scanner;
public class TestWhileLoop {
/**
* @param args the command line arguments
*/
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mp;
/**
*
* @author AMA
*/
import java.util.Scanner;
public class MP {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner mp = new Scanner (System.in);
int input=-1,b=0,c=0;
while (input!=0){
System.out.print("Enter a postive number: ");
input=mp.nextInt();
if (input>0){
c+=input;
System.out.println("Total= " +c);
}
}
System.out.println("Total= " +c);
System.out.print("Done");
}
}