Programming In Java Week 12: Programming Assignments Jan-Jun 2022

  NPTEL PROGRAMMING ASSIGNMENTS

Week 12 : Programming Assignment 1

Due on 2022-04-21, 23:59 IST

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.


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.



Note the following points carefully:
1. Use only doubleto store all numeric values.
2. Each button on the calculator should be operated by typing the characters from 'a' to 't'.
3. You may use the already defined function 
gui_map(char).
4. Use predefined methods from java.lang.Math class wherever applicable.
5. Without '=' binary operations won't give output as shown in Input_3 and Output_3 example below.
5. The calculator should be able to perform required operations on one or two operands as shown in the below example:


Input_1:
okhid

Output_1:
100.0

Input_2:
ia

Output_2:

2.0







 

 



Week 12 : Programming Assignment 2

Due on 2022-04-21, 23:59 IST

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 example:

https://www.xyz.com:1080/index.htm

 

protocol://host:port/filename



import java.net.*;   public class Question2{      public static void main(String[] args){


 

 



Week 12 : Programming Assignment 3

Due on 2022-04-21, 23:59 IST

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 
  "name  rollnumber avgmark".

For example:

input:

ram

das

123

25.5

24.5

output:

ramdas 123 25.0


import java.util.*; public class Question3{   public static void main(String[] args){       Scanner s1 = new Scanner(System.in);


 

 



Week 12 : Programming Assignment 4

Due on 2022-04-21, 23:59 IST

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.

 

class Parent {     public static void testClassMethod() {         System.out.println("The static method.");     }     public void testInstanceMethod() {         System.out.println("The instance method.");     } } public class Child extends Parent {    public static void testClassMethod() { }



 

 



Week 12 : Programming Assignment 5

Due on 2022-04-21, 23:59 IST

Write a recursive function to print the sum of  first n odd integer numbers. The recursive function should have the prototype
 " int sum_odd_n(int n) ".

For example :

input : 
5
output: 
25 

input 
: 6
output : 
36



import java.util.*; public class Question5 {      static int sum_odd_n(int n){            if(n==1)               return 1;            if (n <= 0)                  return 0;




 

 


Post a Comment (0)
Previous Post Next Post