0% found this document useful (0 votes)
5 views5 pages

ASSG1

The document contains Java code examples for basic programming tasks. It includes a simple 'Hello World' program, a command line argument counter, and a program that uses a Scanner to input student details and calculate the total and average of a set of numbers. The code demonstrates fundamental concepts of Java programming such as classes, methods, and user input handling.

Uploaded by

nimisha.bokade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

ASSG1

The document contains Java code examples for basic programming tasks. It includes a simple 'Hello World' program, a command line argument counter, and a program that uses a Scanner to input student details and calculate the total and average of a set of numbers. The code demonstrates fundamental concepts of Java programming such as classes, methods, and user input handling.

Uploaded by

nimisha.bokade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NAME: NIMISHA BOKADE BATCH:C1

Q1)

public class First{

public static void main(String args[]){

[Link]("Hello World");

Q2)

public class comandline{ public static void main(String args[]) { int wordCount =
[Link];

[Link]("Total number of words (arguments): " + wordCount);

}
}

ASSIGNMENT

A)Using scanner get the student name , roll no and marks in one subject form the user

Code:

import [Link];

public class MyObj{ public static void main(String[] args) {


Scanner myObj = new Scanner([Link]);

[Link]("Enter student name:");

String studentName = [Link]();

[Link]("Student name: " + studentName);

[Link]("Enter roll no: ");

int rollNo = [Link]();

[Link]("Roll no: " + rollNo);

[Link]("Enter the marks: "); int marks = [Link]();

[Link]("Marks: " + marks);

[Link]();

}
B) The total and average of n numbers

Code:

import [Link];

class Numbers {

int n; int sum = 0; float average; void calculate() {

Scanner sc = new Scanner([Link]);

[Link]("Enter how many numbers: "); n = [Link]();

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

[Link]("Enter number " + i + ": "); int num = [Link](); sum


+= num;

average = (float) sum / n;

void display() {

[Link]("\nTotal = " + sum);

[Link]("Average = " + average);

public class NumbersMain { public static void main(String[] args) { Numbers obj = new
Numbers(); [Link](); [Link]();

You might also like