adplus-dvertising
NPTEL Programming In Java Assignment 8 Answers 2022 (Week8)

NPTEL Programming In Java Assignment 8 Answers 2022 (Week8)

NPTEL Programming In Java Assignment 8 Answers 2022 :- Here All The Questions and Answers Provided to Help All The Students and NPTEL Candidate as a Reference Purpose, It is Mandetory to Submit Your Weekly Assignment By Your Own Understand Level

 

Are you looking for the Assignment Answers to NPTEL Programming In Java Assignment 8 Answers 2022? If Yes You are in Our Great Place to Getting Your Solution, This Post Should be help you with the Assignment answer to the National Programme on Technology Enhanced Learning (NPTEL) Course “NPTEL Programming In Java Week 8 Assignment Solution 2022

NPTEL Programming In Java Assignment 8 Answers 2022 (Week8)

NPTEL Programming In Java

From My Side : With the expansion of knowledge and Communication Technology, there’s a desire to develop massive and complicated package. Further, those package ought to be platform freelance, web enabled, straightforward to switch, secure, and robust. to satisfy this demand object-oriented paradigm has been developed and supported this paradigm the Java artificial language emerges because the best programming atmosphere. Now, Java artificial language is being employed for mobile programming, web programming, and plenty of alternative applications compatible to distributed systems. This course aims to hide the essential topics of Java programming in order that the participants will improve their skills to address the present demand of IT industries and solve several issues in their own filed of studies.

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.

INTENDED AUDIENCE :  The undergraduate students from the engineering disciplines namely CSE, IT, EE, ECE, etc. might be interested for this course.
PREREQUISITES :  This course requires that the students are familiar with programming language such as C/C++ and data structures, algorithms.
INDUSTRY SUPPORT :   All IT companies.

CRITERIA TO GET A CERTIFICATE

This course can have Associate in Nursing unproctored programming communication conjointly excluding the Proctored communication, please check announcement section for date and time. The programming communication can have a weightage of twenty fifth towards the ultimate score.

Final score = Assignment score + Unproctored programming exam score + Proctored Exam score
  • Assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
  • ( All assignments in a particular week will be counted towards final scoring – quizzes and programming assignments). 
  • Unproctored programming exam score = 25% of the average scores obtained as part of Unproctored programming exam – out of 100
  • Proctored Exam score =50% of the proctored certification exam score out of 100
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF ASSIGNMENT SCORE >=10/25 AND
UNPROCTORED PROGRAMMING EXAM SCORE >=10/25 AND PROCTORED EXAM SCORE >= 20/50. 
If any one of the 3 criteria is not met, you will not be eligible for the certificate even if the Final score >= 40/100. 

CHECK HERE OTHERS NPTEL ASSIGNMENTS ANSWERS 

BELOW YOU CAN GET YOUR NPTEL Programming In Java Assignment 8 Answers 2022? :

NPTEL Programming In Java Assignment 8 Answers 2022 (Week8)

NPTEL Programming In Java Assignment 8 Answers 2022

Q1. Which of the following is NOT a class of java.awt package?

a) Button
b) Component
c) Dialog
d) Paint

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: d) Paint

Q2. Which of the following is/are NOT an exception of java.awt package?

a) AWTError
b) AWTException
c) FontFormatException
d) all of these

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: a) AWTError

Q3. Which of the following method is/are a class button of java.awt package?

a) paint(Graphics g)
b) setLabel(String label)
c) getCurrent()
d) getIntern(int index)

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: b) setLabel(String label)

Q4. Which of the following container does not contain titlebar and menubar?

a) window
b) panel
c) container
d) frame

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: b) panel

Q5. Which package provides many event classes and Listener interfaces for event handling?

a) java.awt.activeevent
b) java.awt.event
c) java.awt.listener
d) none of these

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: b) java.awt.event

Q6. What is the name of the method used to get the current fond of an graphic in java.awt.graphics?

a) abstract FontMetrics getFontMetrices(Font f)
b) abstract Font getFont()
c) FontMetrices getFontMetrics()
d) None of these

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: b) abstract Font getFont()

Q7. Which of the following method remove all items from scrolling list in java.awt.list?

a) hide()
b) clear()
c) remove()
d) None

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: b) clear()

Q8. Which of the following statement is true about the update() in java.awt.package?

a) Sets the color of the graphics context to be the foreground color of this component
b) Calls this component’s paint method to completely redraw this component
c) Clears this component by filling it with the background color
d) All of these

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: d) All of these

Q9. Which of the following methods can be used to return the current size of a java.awt.Component object?

a) dimension()
b) setSize()
c) area()
d) size()
e) resize()

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: d) size()

Q10. When we invoke update() for a java.awt.Component object, the AWT invokes which of the following method?

a) show()
b) draw()
c) paint()
d) repaint()

SHOW Answer By SciShowEngineer
Answer By SciShowEngineer: c) paint()

Programming in Java Assignment 8 All Answer

NPTEL Programming In Java Assignment 8 Answers 2022 (Week8)

1. Write a program which will print a pyramid of “*” ‘s of height “n” and print the number of “*” ‘s in the pyramid.
For example:
Input : 5
Output:
        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *
25
Solution :

import java.util.*;
public class Pattern1 {
public static void main(String[] args) {
Scanner inr = new Scanner(System.in);
int n = inr.nextInt();
// Add the necessary code in the below space
int k=0, s=0;

for(int i=1;i<=n;++i,k=0){

for(int j =1;j<=n-i;++j){

System.out.print(” “);

}

while(k !=2 *i-1){

System.out.print(“* “);

s=s+1;

++k;

 

}

System.out.println();

}

System.out.println(s);

}

}

Q2.

Write a program which will print a pascal  pyramid of  “*” ‘s of height “l” .
For example:

input: 8
output :
       *
      * *
     * * *
    * * * *
   * * * * *
  * * * * * *
 * * * * * * *
* * * * * * * *
Solution :
import java.util.*;
public class Pattern2 {
public static void main(String[] args) {
Scanner inr = new Scanner(System.in);
int l = inr.nextInt();
// Add the necessary code in the below space
int i,j;
int space=l-1;
/*run loop (parent loop) till number of rows*/
for(i=0;i< l;i++)
{
/*loop for initially space, before star printing*/
for(j=0;j< space;j++)
{
System.out.print(” “);
}
for(j=0;j<=i;j++)
{
System.out.print(“* “);
}
System.out.print(“\n”);
space–; /* decrement one space after one row*/
}
}
}
Q3.

Write a program which will print a pyramid of “numbers” ‘s of height “n” and print the sum of all number’s in the pyramid.
For example:
input: 5
output:
        1
      1 2 3
    1 2 3 4 5
  1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
95
Solution:
import java.util.*;
public class Pattern3 {
public static void main(String[] args) {
Scanner inr = new Scanner(System.in);
int n = inr.nextInt();
// Add the necessary code in the below space
int k = 1,sum=0;
for(int i = 1; i <= n; ++i, k = 1) {
for(int space = 1; space <= n-i; ++space) {
System.out.print(” “);
}
while(k <= 2 * i – 1) {
System.out.print(k+” “);
sum=sum+k;
++k;
}
System.out.println();
}
System.out.println(sum);
}
}
Q4.

Write a program to print symmetric Pascal’s triangle of “*” ‘s of  height “l” of odd length . If input “l” is even then your program will print “Invalid line number”.
For example:

input : 5
output:
  *
 * *
* * *
 * *
  *
input : 6
output:
Invalid line number
Solution :

import java.util.*;
public class Pattern4 {
public static void main(String[] args) {
Scanner inr = new Scanner(System.in);
int l = inr.nextInt();
int ul=0; // Upper Line
int ll=0; // Lower Line

// Check whether line number is odd
if (l%2!=0){
ul=(l/2)+1;
ll=l-ul;
//Code for upper half
for(int i=1;i<=ul; i++){
//Space management
for(int s=1;s<=(ul-i); s++){
System.out.print(” “);
}
// Star management
for(int j=1;j<=i; j++){
System.out.print(“* “);
}
System.out.println();
}

//Code for lower half
int llc=ll;
for(int i=1;i<=ll; i++){
//Space management
for(int s=llc;s<ll; s++){
System.out.print(” “);
}
// Star management
for(int j=1;j-1<=ll-i; j++){
System.out.print(” *”);
}
llc–;
System.out.println();
}
}
else{
System.out.print(“Invalid line number”);
}

}
}

Q5.

Write a program to display any digit(n) from 0-9 represented as a “7 segment  display”.
For example:
input : 5
output :
 _
|_
 _|
input : 4
output :
|_|
   |
Solution :

import java.util.*;

public class Pattern5 {

private static final Map<Integer, Integer> encodings =
new HashMap<Integer, Integer>();

static {
encodings.put(0, 0x7E);
encodings.put(1, 0x30);
encodings.put(2, 0x6D);
encodings.put(3, 0x79);
encodings.put(4, 0x33);
encodings.put(5, 0x5B);
encodings.put(6, 0x5F);
encodings.put(7, 0x70);
encodings.put(8, 0x7F);
encodings.put(9, 0x7B);
}

public static void printDigit(int digit) {
int code = encode(digit);
char[] bits =
String.format(“%7s”, Integer.toBinaryString(code))
.replace(‘ ‘, ‘0’).toCharArray();

lightSegment(bits[0] == ‘1’, ” _ \n”, ” \n”);
lightSegment(bits[5] == ‘1’, “|”, ” “);
lightSegment(bits[6] == ‘1’, “_”, ” “);
lightSegment(bits[1] == ‘1’, “|\n”, ” \n”);
lightSegment(bits[4] == ‘1’, “|”, ” “);
lightSegment(bits[3] == ‘1’, “_”, ” “);
lightSegment(bits[2] == ‘1’, “|\n”, ” \n”);
}

private static void lightSegment(boolean on, String onValue, String offValue) {
System.out.print(on ? onValue : offValue);
try {
Thread.sleep(0);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}

private static int encode(int digit) {
return encodings.containsKey(digit) ? encodings.get(digit) : 0x00;
}
public static void main(String[] args) throws Exception {
Scanner inr = new Scanner(System.in);
int n = inr.nextInt();
printDigit(n);

}
}

Related Posts

One thought on “NPTEL Programming In Java Assignment 8 Answers 2022 (Week8)

  1. Excellent blog! Do you have any recommendations for aspiring writers? I’m planning to start my own website soon but I’m a little lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m completely confused .. Any recommendations? Kudos!

Leave a Reply

Your email address will not be published.