Professional Documents
Culture Documents
Assingment
Assingment
import java.util.*;
import java.io.*;
class Ftmsk {
public static void main (String[]args){
BufferedReader in = null;
PrintWriter outcs110 = null;
PrintWriter outcs111 = null;
try {
int cs110 = 0;
int cs111= 0;
matNum[ct] = st.nextToken();
name[ct] = st.nextToken();
prog[ct] = st.nextToken();
String pa = st.nextToken();
part[ct] = Integer.parseInt(pa);
ct++;
}
in.close();
outcs110.close();
outcs111.close();
}
catch ( FileNotFoundException fe)
{
System.out.println(fe.getMessage());
}
output
Question 2
import java.util.*;
import java.io.*;
class Customer {
try {
FileReader fr = new FileReader ("order.txt");
BufferedReader in = new BufferedReader (fr);
custPackage =input.nextToken();
c = new
Customer(custName,custAddress,productID,quantity,custPackage);
if ( c.getproductID() == 101)
subtotal = 200 * quantity;
else if (c.getproductID() == 102)
subtotal = 170 * quantity;
else if ( c.getproductID() == 103)
subtotal = 350 * quantity ;
else if (c.getproductID() == 104)
subtotal = 500 * quantity;
if ( c.getpakej().equalsIgnoreCase("Student"))
{ total = total - (total * 0.1);
printStud.println(c +"\t\t Total : " +total);
}
if (c.getpakej().equalsIgnoreCase("Staff"))
printStaff.println(c +"\t\tTotal: " +total);
data = in.readLine();
}
printStaff.close();
printStud.close();
}
catch (FileNotFoundException fnfe){
System.out.println(fnfe.getMessage());}
catch (Exception e ){
System.out.println("Problem : " + e.getMessage());}
}}
output
Question 3
import java.util.*;
import java.io.*;
class Hfmd{
public static void main (String [] args){
try{
String state;
int case2017,case2018,total2017 = 0, total2018 = 0 ;
}
outFile.println("Total cases for 2017 is : " +
total2017);
outFile.println("Total cases for 2018 is : " +
total2018);
inFile.close();
outFile.close();
}
Output