You are on page 1of 4

Week 12 : Programming Assignment 1

outerloop:

for(int i=0; i<seq.length; i++){

if(seq[i]=='C'){

operand1=0.0;

operand2=0.0;

output=0.0;

outflag=0;

break outerloop;

}else if(seq[i]=='R'){

for(int j=0; j<i; j++){

o1+=Character.toString(seq[j]);

operand1=Double.parseDouble(o1);

output=Math.sqrt(operand1);

outflag=1;

break outerloop;

else if(seq[i]=='S'){

for(int j=0; j<i; j++){

o1+=Character.toString(seq[j]);

operand1=Double.parseDouble(o1);

output=Math.pow(operand1,2);

outflag=1;

break outerloop;

}else if(seq[i]=='F'){
for(int j=0; j<i; j++){

o1+=Character.toString(seq[j]);

operand1=Double.parseDouble(o1);

output=Math.pow(operand1,-1);

outflag=1;

break outerloop;

}else{

int r=0;

if(seq[i]=='+'||seq[i]=='-'||seq[i]=='/'||seq[i]=='*'||seq[i]=='='){

for(int j=0; j<i; j++){

o1+=Character.toString(seq[j]);

operand1=Double.parseDouble(o1);

for(int k=i+1; k<seq.length; k++){

if(seq[k]=='='){

outflag=1;

operand2=Double.parseDouble(o2);

if(seq[i]=='+'){

output=operand1+operand2;

}else if(seq[i]=='-'){

output=operand1-operand2;

}else if(seq[i]=='/'){

output=operand1/operand2;

}else if(seq[i]=='*'){

output=operand1*operand2;

}
break outerloop;

}else{

o2+=Character.toString(seq[k]);

Week 12 : Programming Assignment 2

try{

URL url=new URL("http://www.Nptel.com/java-tutorial");

System.out.println("Protocol: "+url.getProtocol());

System.out.println("Host Name: "+url.getHost());

catch(Exception e){System.out.println(e);}

Week 12 : Programming Assignment 3

String f = s1.next();

String l = s1.next();

int n = s1.nextInt();

double db = s1.nextDouble();
double db1 = s1.nextDouble();

double avg=(db+db1)/2;

System.out.println(f + l +" "+ n +" "+avg );

Week 12 : Programming Assignment 4

public static void main(String[] args) {

Child c= new Child();

c.testInstanceMethod();

Parent.testClassMethod();

Week 12 : Programming Assignment 5

return 2*n-1 + sum_odd_n(n-1);

You might also like