NPTEL Programming In Java Assignment 12 Answers 2022

NPTEL Programming In Java Assignment 12

Are you looking for the Answers to NPTEL Programming In Java Assignment 12? This article will help you with the answer to the National Programme on Technology Enhanced Learning (NPTEL) Course NPTEL Programming In Java Assignment 12

What is Programming In Java?

With the growth of Information and Communication Technology, there is a need to develop large and complex software. Further, those software should be platform independent, Internet enabled, easy to modify, secure, and robust. To meet this requirement object-oriented paradigm has been developed and based on this paradigm the Java programming language emerges as the best programming environment. Now, Java programming language is being used for mobile programming, Internet programming, and many other applications compatible to distributed systems. This course aims to cover the essential topics of Java programming so that the participants can improve their skills to cope with the current demand of IT industries and solve many problems in their own filed of studies.

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of best 12 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

Below you can find the answers for NPTEL Programming In Java Assignment 12

Assignment No.Answers
Programming In Java Assignment 1 Click Here
Programming In Java Assignment 2 Click Here
Programming In Java Assignment 3 Click Here
Programming In Java Assignment 4 Click Here
Programming In Java Assignment 5 Click Here
Programming In Java Assignment 6 Click Here
Programming In Java Assignment 7 Click Here
Programming In Java Assignment 8 Click Here

NPTEL Programming In Java Assignment 12 Answers:-

Q1. Complete the code to develop an extended version of the ADVANCED CALCULATOR with added special functions that emulates all the functions of the GUI Calculator as shown in the image.

For Week 12 MCQ/Quiz Answers Click Me

 char seq[] = input.toCharArray();
		int outflag=0;
		
		for(int i=0; i<seq.length; i++){
			seq[i]=gui_map(seq[i]);
		   if (seq[i]=='R' || seq[i]=='S' || seq[i]=='F' ||seq[i]=='C')
				break;
		}
		//Print Mapped GUI (remove comment to see the mapped sequence input)
		/*
		for(int i=0; i<seq.length; i++){
			System.out.print(seq[i]);
		}
		*/
		// Use double type of values for entire calculation
		double operand1=0.0;
		String o1="";
		double operand2=0.0;
		String o2="";
		double output=0.0;

	
outerloop:
		for(int i=0; i<seq.length; i++){
			if(seq[i]=='C'){				//Clear
				operand1=0.0;
				operand2=0.0;
				output=0.0;
				outflag=0;
				break outerloop;
			}else if(seq[i]=='R'){			//Square Root
				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'){			//Square
				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'){			//Inverse
				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]=='\0'||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]);
						}
					}
				}
			}
		}
// Check if output is available and print the output
		if(outflag==1)
			System.out.print(output);

Q2. A partial code fragment is given. The URL class object is created in try block.You should write appropriate method( )  to print the protocol name and host name from the given url string.

For Online programming test help and final exam preparation material Click Me

try{  
     URL url=new URL("http://www.Nptel.com/java-tutorial");    
    //use appropriate method() to print the protocol name and host name from url 
    //Write the method() by replacing the blank space.
    System.out.println("Protocol: "+url.getProtocol());  
     System.out.println("Host Name: "+url.getHost());  
   
 
      }
   catch(Exception e){System.out.println(e);}  
   }  
}
quizxp telegram

Q3. Write a program to create a record by taking inputs using Scanner class as first name as string ,last name as string ,roll number as integer ,subject1 mark as float,subject2 mark as float. Your program should print in the format 

  //Read your first name
    String f = s1.next();
    //Read your last name
    String l = s1.next();
    //Read rollnumber
    int n = s1.nextInt();
    //Read 1st subject mark
       double db = s1.nextDouble();
	//Read 2nd subject mark
	double db1 = s1.nextDouble();
	double avg=(db+db1)/2;
	System.out.println(f + l +" "+ n +" "+avg );

Q4. A program code is given to call the parent class static method and instance method in derive class without creating object of parent class. You should write the appropriate code so that the program print the contents of static method() and instance method () of parent class.

public static void main(String[] args) {
  
// Call the instance method in the Parent class 
    Child c= new Child();
    c.testInstanceMethod();
		
     // Call the static method in the Parent class
    Parent.testClassMethod();
    
}
}

Q5.Write a recursive function to print the sum of  first n odd integer numbers. The recursive function should have the prototype

For Online programming test help and final exam preparation material Click Me

//Call the method recursively.
return 2*n-1 + sum_odd_n(n-1);

For other courses answers:- Visit

For Internship and job updates:- Visit

Disclaimer: We do not claim 100% surety of answers, these answers are based on our sole knowledge, and by posting these answers we are just trying to help students, so we urge do your assignment on your own.

if you have any suggestions then comment below or contact us at [email protected]

If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.

NPTEL Programming In Java Assignment 12 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge.