import java.util.Scanner; // needed for Scanner
/** A Java program that demonstrates console based input and output. */
public class MyConsoleIO
{
// Create a single shared Scanner for keyboard input
private static Scanner scanner = new Scanner( System.in );
// Program execution starts here
public static void main ( String [] args )
{
// Prompt the user
System.out.print( "Enter your Bengali score: " );
int bengali = scanner.nextInt();
System.out.print( "Enter your English score: " );
int english = scanner.nextInt();
System.out.print( "Enter your Math score: " );
int math = scanner.nextInt();
int total=bengali+english+math;
// Read a line of text from the user.
// String input = scanner.nextLine();
// Display the input back to the user.
System.out.println( "Total = " + total );
} // end main method
} // end MyConsoleIO class
import java.util.Scanner;
public class Manager {
public static void main(String[] args) {
ShowMessag Tushar=new ShowMessag();
TakeInput Tushar1=new TakeInput();
Tushar.BanglaMarks();
Tushar1.BanglaInput();
Tushar.EnglishMarks();
Tushar1.EnglishInput();
Tushar.MathMarks();
Tushar1.MathMarks();
Tushar1.TotalMarks();
}
}
class ShowMessag {
public void BanglaMarks(){
System.out.println("Give Bangla Marks");
}
public void EnglishMarks(){
System.out.println("Give English Marks");
}
public void MathMarks(){
System.out.println("Give Math Marks");
}
}
class TakeInput {
int bengali;
int english;
int math;
private static Scanner scanner = new Scanner( System.in );
public TakeInput(){
this.bengali=0;
this.english=0;
this.math=0;
}
public void BanglaInput(){
bengali = scanner.nextInt();
}
public void EnglishInput(){
english = scanner.nextInt();
}
public void MathMarks(){
math = scanner.nextInt();
}
public void TotalMarks(){
System.out.println("Total="+bengali+english+math);
}
}this above code example was incomplete and sent by one of my NCC student and i just solve his problem so that i paste it here.
Comments 2