import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class Exercise19{
public static void main(String[]args)
{
double h=0;
double v=0;
double c=0;
double t;
int boss=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter the Volume of cylinder"));
int boss1=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter the Radius of cylinder"));
double j = Math.pow(boss1, 2);
h=boss/3.16*j;
c=2*3.16 * j*(j+h);
DecimalFormat fomat = new DecimalFormat("###.##");
JOptionPane.showMessageDialog(null,"Height : " + fomat.format(h) + "\nCost : " + c);
}
}
Friday, August 16, 2013
Exercise no. 18
import javax.swing.JOptionPane;
public class Exercise18 {
public static void main(String []args)
{
int score=0;
int score1=0;
for(int x=1;x<=9;x++)
{
score=Integer.parseInt(JOptionPane.showInputDialog(null, "Team A " + "\n" + "Enter Runs Score " + " inning [" + x + "]"));
score=score+score;
}
for(int y=1;y<=9;y++)
{
score1=Integer.parseInt(JOptionPane.showInputDialog(null, "Team B " + "\n" +" Enter Runs Score "+ " inning [" + y + "]"));
score1=score1+score1;
}
JOptionPane.showMessageDialog(null, "Total Score of Team A : " + score + "\n" + "Total Score of Team B :" + score1);
}
}
public class Exercise18 {
public static void main(String []args)
{
int score=0;
int score1=0;
for(int x=1;x<=9;x++)
{
score=Integer.parseInt(JOptionPane.showInputDialog(null, "Team A " + "\n" + "Enter Runs Score " + " inning [" + x + "]"));
score=score+score;
}
for(int y=1;y<=9;y++)
{
score1=Integer.parseInt(JOptionPane.showInputDialog(null, "Team B " + "\n" +" Enter Runs Score "+ " inning [" + y + "]"));
score1=score1+score1;
}
JOptionPane.showMessageDialog(null, "Total Score of Team A : " + score + "\n" + "Total Score of Team B :" + score1);
}
}
Exercise17
import javax.swing.JOptionPane;
public class Exercise17 {
public static void main(String[]args)
{
String [] month = new String []{"Januray","February","March","April","May"
,"June","July","August","September","October","November","December"};
for(String year : month)
{
JOptionPane.showMessageDialog(null,"Month of " + year );
}
}
}
public class Exercise17 {
public static void main(String[]args)
{
String [] month = new String []{"Januray","February","March","April","May"
,"June","July","August","September","October","November","December"};
for(String year : month)
{
JOptionPane.showMessageDialog(null,"Month of " + year );
}
}
}
Exercise no. 14
import javax.swing.JOptionPane;
public class Exercise14 {
public static void main(String [] args)
{
String squares;
squares=JOptionPane.showInputDialog(null,"Enter the number");
int s=Integer.parseInt(squares);
int a=0,x=0;
for ( ;x<=s;x++)
{
Math.pow(x,2);
}
JOptionPane.showMessageDialog(null,"The sum of Square is : " + Math.pow(x,2));
}
}
public class Exercise14 {
public static void main(String [] args)
{
String squares;
squares=JOptionPane.showInputDialog(null,"Enter the number");
int s=Integer.parseInt(squares);
int a=0,x=0;
for ( ;x<=s;x++)
{
Math.pow(x,2);
}
JOptionPane.showMessageDialog(null,"The sum of Square is : " + Math.pow(x,2));
}
}
Exercise no. 13
import javax.swing.JOptionPane;
public class Exercise13 {
public static void main(String[]args)
{
int s=0,f=0;
int d=1;
String userstring = JOptionPane.showInputDialog(null,"Enter number");
int userint = Integer.parseInt(userstring);
do{
if(d%2==1)
{
s++;
}
if(s<=userint)
{
f+=s;
}
d=d+1;
}
while(s!=userint);
JOptionPane.showMessageDialog(null,"The sum of first is " + userstring + " and positive odd integer is : " + f);
}
}
public class Exercise13 {
public static void main(String[]args)
{
int s=0,f=0;
int d=1;
String userstring = JOptionPane.showInputDialog(null,"Enter number");
int userint = Integer.parseInt(userstring);
do{
if(d%2==1)
{
s++;
}
if(s<=userint)
{
f+=s;
}
d=d+1;
}
while(s!=userint);
JOptionPane.showMessageDialog(null,"The sum of first is " + userstring + " and positive odd integer is : " + f);
}
}
Tuesday, August 6, 2013
Exercise No. 10
import java.util.Scanner;
public class Prime {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int x, y =2;
String value;
System.out.print("Enter A Number: ");
x = s.nextInt();
while (x != 0){
if (y<x){
if(x%y==0){
value= "Is Not A Prime";
System.out.print(value);
break;}
else{
y++;
continue;}
}
else{
value = "Is A Prime";
System.out.print(value);
break;}
}
}
}
public class Prime {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int x, y =2;
String value;
System.out.print("Enter A Number: ");
x = s.nextInt();
while (x != 0){
if (y<x){
if(x%y==0){
value= "Is Not A Prime";
System.out.print(value);
break;}
else{
y++;
continue;}
}
else{
value = "Is A Prime";
System.out.print(value);
break;}
}
}
}
Saturday, August 3, 2013
Exercise no. 4
import java.util.*;
public class MileAge {
public static void main(String[] args) {
Scanner x= new Scanner(System.in);
double milesdriven,gallonsused,milespergallon;
System.out.println("Enter Miles Driven: ");
milesdriven=x.nextDouble();
System.out.println("Enter Gallons Used: ");
gallonsused=x.nextDouble();
milespergallon=milesdriven/gallonsused;
System.out.println("The Miles Per Gallon Is: "+milespergallon);
}
}
public class MileAge {
public static void main(String[] args) {
Scanner x= new Scanner(System.in);
double milesdriven,gallonsused,milespergallon;
System.out.println("Enter Miles Driven: ");
milesdriven=x.nextDouble();
System.out.println("Enter Gallons Used: ");
gallonsused=x.nextDouble();
milespergallon=milesdriven/gallonsused;
System.out.println("The Miles Per Gallon Is: "+milespergallon);
}
}
Subscribe to:
Posts (Atom)