Skip to main content

Week 7 Programming Assignment : Programming in JAVA 2023

 

What is Programming in Java?

Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications.

Here are some key features and concepts of Java programming:

Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data.

Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development.

Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code.

Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can recover gracefully from unexpected errors.

Multi-threading: Java supports multi-threading, which allows programs to execute multiple threads of execution simultaneously, making it well-suited for developing concurrent applications.

Standard libraries: Java provides a large number of standard libraries that developers can use to build applications more quickly and easily, including libraries for networking, database access, and user interface development.

To get started with Java programming, you will need to install the Java Development Kit (JDK) on your computer. Once you have installed the JDK, you can use an Integrated Development Environment (IDE) like Eclipse or IntelliJ IDEA to write and debug your code.

To learn Java programming, you can start with the basics of the language, such as data types, control structures, and object-oriented programming concepts. There are many online resources and tutorials available for learning Java, including Oracle's official Java tutorials, which cover everything from the basics to advanced topics like concurrency and networking.

Week 7: Programming Assignment 1

Due on 2023-03-16, 23:59 IST
A byte char array is initialized. You have to enter an index value"n". According to index your program will print the byte and its corresponding char value.
Complete the code segment to catch the exception in the following, if any. On the occurrence of such an exception, your program should print “exception occur” .If there is no such exception, it will print the required output.

Solution :

String s2 = new String(barr,n,1);  
        System.out.println(barr[n]);
	System.out.println(s2); 
	}


Week 7 : Programming Assignment 2

Due on 2023-03-16, 23:59 IST
The following program reads a string from the keyboard and is stored in the String variable "s1". You have to complete the program so that it should should print the number of vowels in s1 . If your input data doesn't have any vowel it will print "0".

Solution :

for(int i=0;i<s1.length();i++){  
          char s2=s1.charAt(i);
          if(s2=='e' || s2=='E'|| s2=='a' || s2=='A' || s2=='i' || s2=='I' || s2=='o' || s2=='O' || s2=='u' || s2=='U') 
	     {
	       c=c+1;
             }    
         } 


Week 7 : Programming Assignment 3

Due on 2023-03-16, 23:59 IST
A string "s1" is already initialized. You have to read the index "n"  from the keyboard. Complete the code segment to catch the exception in the following, if any. On the occurrence of such an exception, your program should print “exception occur” .If there is no such exception, your program should replace the char "a" at the index value "n" of the "s1" ,then it will print the modified string.

Solution :

  byte[] barr=s1.getBytes();   
	      
                byte b1 = (byte) c;
            	barr[n]=b1;
		System.out.println(new String(barr)); 
	   }


Week 7 : Programming Assignment 4

Due on 2023-03-16, 23:59 IST
Complete the following code fragment to read three integer values from the keyboard and find the sum of the values. Declare a variable "sum" of type int and store the result in it.

Solution :

 import java.util.*;
        public class Question1{ 
        public static void main (String[] args){ 
	        
             int i,n=0,sum=0;
             Scanner inr = new Scanner(System.in);
		for (i=0;i<3;i++)
		{
		    n = inr.nextInt();
		    
  		sum =sum+n;
         	}


Week 7 : Programming Assignment 5

Due on 2023-03-16, 23:59 IST
Complete the code segment to catch the exception in the following, if any. On the occurrence of such an exception, your program should print “Please enter valid data” .If there is no such exception, it will print the "square of the number".

Solution :

 try {  
   InputStreamReader r=new InputStreamReader(System.in);  
   BufferedReader br=new BufferedReader(r);  
   String number=br.readLine();  
   int x = Integer.parseInt(number);
   System.out.println(x*x);
    }
   catch (Exception e){
       System.out.println("Please enter valid data");
    }

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of the best 8 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 THE 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.

Programming in JAVAAnswers
Assignment 1Click Here
Assignment 2Click Here
Assignment 3Click Here
Assignment 4Click Here
Assignment 5Click Here
Assignment 6Click Here
Assignment 7Click Here
Assignment 8Click Here
Assignment 9NA
Assignment 10NA
Assignment 11NA
Assignment 12NA

Comments

Popular posts from this blog

Week 3 Programming Assignment : Programming in Modern C++ 2023

  What is Programming in Modern C++? This course introduces problem-solving and programming using the C++ programming language. The topics include: Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.  Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants. Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed. Standard Library of C++. The string, vector, and map classes. W3_Programming_Qs-1 Due on 2023-02-16, 23:59 IST Consider the program below. Fill in the bl...

Week 11 Programming Assignment : Programming in JAVA 2023

  What is Programming in Java? Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications. Here are some key features and concepts of Java programming: Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data. Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development. Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code. Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can re...

Week 4 Programming Assignment : The Joy of Computing using Python 2023

  What is The Joy of Computing using Python? Python is a popular programming language that is easy to learn and widely used for various applications such as web development, data science, and artificial intelligence. Learning Python can be a joyous experience as it allows you to create your own programs, automate tasks, and solve real-world problems. Here are some tips to help you experience the joy of computing using Python: Start with the basics: Before diving into advanced topics, it is essential to learn the basics of Python such as syntax, data types, and control structures. This will help you build a strong foundation and make it easier to learn more advanced topics. Practice coding: The more you practice coding, the better you will get at it. You can start by writing simple programs and gradually move on to more complex ones. There are also many online resources such as coding challenges and competitions that can help you improve your coding skills. Learn from others: There ...

Week 2 Programming Assignment : Programming in Modern C++ 2023

  What is Programming in Modern C++? This course introduces problem-solving and programming using the C++ programming language. The topics include: Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.  Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants. Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed. Standard Library of C++. The string, vector, and map classes. W2_Programming_Qs-1 Due on 2023-02-09, 23:59 IST Consider the program below. • Fill in th...

Week 1 Programming Assignment : Programming in Modern C++ 2023

  What is Programming in Modern C++? This course introduces problem-solving and programming using the C++ programming language. The topics include: Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.  Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants. Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed. Standard Library of C++. The string, vector, and map classes. W1_Programming_Qs_1 Due on 2023-02-09, 23:59 IST Consider the program below. • Fill in the ...

Week 2 Programming Assignment : Programming in JAVA 2023

  What is Programming in Java? Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications. Here are some key features and concepts of Java programming: Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data. Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development. Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code. Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can re...

Week 9 Programming Assignment : Programming in JAVA 2023

  What is Programming in Java? Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications. Here are some key features and concepts of Java programming: Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data. Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development. Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code. Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can re...