Monday, March 20, 2006

Homework 3/13

Tax

package s9226307;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class s9226307 {
public s9226307() {

}
public static void main(String[] args)throws IOException
{

BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
double wealth,tax;
System.out.println("Enter your wealth:");
String podString = keyboard.readLine();
wealth=Integer.parseInt(podString);
if(wealth<=370000)
tax=0;
else if((wealth>370000)&&(wealth<=990000))
tax=(wealth-370000)*0.13+25900;
else if((wealth>)&&(wealth<=1980000))
tax=(wealth-990000)*0.21;+105100
else if((wealth>)&&(wealth<=3720000))
tax=(wealth-1980000)*0.3;+283300
else{
tax=(wealth-655300)*0.4;
}
System.out.println("Tax due=$"+tax);
}
}




find the max and min

package s9226307;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class s9226307{
public s9226307(){
}
public static void main(String[] args)throws IOException
{
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter some nonnegative numbers:");
System.out.println("Mark the end with a negaive number.");
System.out.println("I will compare Max and min");
double max=-1,min=-1,num=0;
int count=0;
String input="";
while(num >= 0)
{
input = keyboard.readLine();
num = Double.parseDouble(input);
if ((max==-1)||(num>=max)&&num>=0)
max = num;
if((min==-1)||(num<=min)&&num>=0)
min = num;
count++;
}

if (count==0)
System.out.println("No numbers entered.");
else
{
System.out.println("There are "+count+" numbers read.");
System.out.println("The max is "+max+" and the min is "+min);
}
}
}

0 Comments:

Post a Comment

<< Home