Assignment 7

import java.io.*;
class ArcCircle
{
  public static void main (String[] args) throws IOException
  { 
    BufferedReader buffer = 
      new BufferedReader (new InputStreamReader(System.in));
 
    String inData;
    double   radius, area ;
    double pi;
    pi=3.14;

    System.out.println("Enter the radius to calculate the area:");
    inData = buffer.readLine();
    
    radius   = Integer.parseInt( inData ); 
    area = radius * radius * pi ;                 

    System.out.println("The area of the circle with a radius of " + radius + " is " + area);
  }
}
import java.io.*;
class DtoC
{
  public static void main (String[] args) throws IOException
  { 
    BufferedReader buffer = 
      new BufferedReader (new InputStreamReader(System.in));
 
    String inData;
    int    dollars, centsEnter, convert, cents ;
    convert=100;

    System.out.println("Enter the number of cents to be converted into dollars:");
    inData = buffer.readLine();
    
    centsEnter  = Integer.parseInt( inData ); 
    dollars = centsEnter / convert ; 
    cents = centsEnter % convert;

    System.out.println(centsEnter +" cents equals " + dollars + " dollars and " + cents + " cents.");
  }
}

import java.io.*;
class change
{
  public static void main (String[] args) throws IOException
  { 
    BufferedReader buffer = 
      new BufferedReader (new InputStreamReader(System.in));
 
    String inData;
    int centsEnter, cents, nickels, dimes, quarters, dollars; 
   
    System.out.println("Enter the number of cents to be converted into change: ");
    inData = buffer.readLine();
    
    centsEnter  = Integer.parseInt( inData ); 
     dollars = centsEnter / 100;
     quarters = (centsEnter - (dollars * 100)) / 25;
     dimes = (centsEnter - (dollars * 100) - (quarters * 25)) / 10;
     nickels = (centsEnter - (dollars * 100) - (quarters * 25) - (dimes * 10)) / 5;
     cents = (centsEnter - (dollars * 100) - (quarters * 25) - (dimes * 10) - (nickels * 5));

    System.out.println("Change from " + centsEnter +"equals " + dollars + " dollars, " + quarters 
    + " quarters, " + dimes + " dimes, " + nickels + " nickels, and " + cents + " cents." );
  }
}
import java.io.*;
class Ohm
{
  public static void main (String[] args) throws IOException
  { 
    BufferedReader buffer = 
      new BufferedReader (new InputStreamReader(System.in));
       BufferedReader buffer2 = 
      new BufferedReader (new InputStreamReader(System.in));
 
    String inData;
    double resistance, current, voltage; 
    String inData2;
   
    System.out.println("Enter the voltage: ");
    inData = buffer.readLine();
    System.out.println("Enter the resistance: ");
    inData2 = buffer2.readLine();
    
    voltage  = Integer.parseInt( inData ); 
    resistance = Integer.parseInt( inData2 ); 
    current = (voltage + 0.0) / resistance;
    System.out.println("current = " + current );
  }
}
Hosted by www.Geocities.ws

1