write a program that accepts your name age total marks and display these line by line and also last to display a thank you message
Answers
Answer :-
//The following program is done using java programming language.
import java.util.Scanner;
class AboutMe{
public static void main (String ar []){
Scanner sc=new Scanner(System.in);
System.out.print("Enter your name : ");
String name=sc.nextLine();
System.out.print("Enter your age : ");
int age=sc.nextInt();
System.out.print("Enter total marks scored in all the subjects : ");
int marks=sc.nextInt();
System.out.println("------------OUTPUT------------");
System.out.println("Name : "+ name);
System.out.println("Age : "+ age);
System.out.println("Total Marks Scored :"+marks);
System.out.println("-----Thank You-----");
}
}
#The following program has been done in python.
print("Enter your name:")
name=input()
print("Enter your age:")
age=int(input())
print("Enter total marks scored in all the subjects :")
marks=int(input())
print(f"Name : {name}\nAge : {age}\nTotal Marks Scored : {marks}\n-----Thank You-----")
//The following program has been done in cpp.
#include <iostream>
using namespace std;
int main() {
string name;
int marks,age;
cout<<"Enter your name:";
getline(cin, name);
cout<<endl<<"Enter your age :";
cin>>age;
cout<<endl<<"Enter total marks scored in all the subjects :";
cin>>marks;
cout<<endl<<"-------Output------";
cout<<endl<<"Name:"<<name;
cout<<endl<<"Age:"<<age;
cout<<endl<<"Total marks scored:"<<marks;
cout<<endl<<"-----Thank You-----";
return 0;
}
import java.util.Scanner; // imports Scanner class.
public class Main { // Declares the class name as "Main".
public static void main(String [] args) { // Main method.
Scanner usin = new Scanner(System.in); // Activates the Scanner as "usin".
System.out.println("Please enter your name: "); // Asks for input.
String name = usin.nextLine(); // takes input.
System.out.println("Please enter your age: "); // Asks for input.
int age = usin.nextInt(); // takes input.
System.out.println("Please enter the total marks scored by you: "); // Asks for input.
int marks = usin.nextInt(); // takes input.
System.out.println("\n\n\n"); // prints new lines.
System.out.println("Your name - " + name); // Prints name.
System.out.println("Your age - " + age); // Prints age.
System.out.println("Total marks scored by you - " + marks); // Prints total marks.
System.out.println("Thanks for viewing this code."); // The thank you message.
}
}
#include <iostream> // includes iostream header file
# include <string> // includes string header file.
using namespace std; // declares that it is using standard namespace.
int main() { // The main method.
string name, age, marks; // declares three stirngs.
cout << "Please enter your name: "; // Asks for input.
getline(cin, name); // Takes input
cout << "Please enter your age: "; // Asks for input.
cin >> age; // Takes input.
cout << "Please enter the total marks scored by you: "; // Asks for input.
cin >> marks; // Takes input.
cout << "Your name - " << name << endl << "Your age - " << age << endl << "Marks scored by you - " << marks << endl << "Thanks for viewing the code."; // prints name, age, marks, thanks.
return 0; // returns 0.
}
print("Please enter your name: ") # Asks for input.
name = input() # Takes input
print("Please enter your age: ") # Asks for input.
age = input() # Takes input.
print("Please enter your marks: ") # Asks for input.
marks = input() # Takes input.
print("Your name - " + name) # prints name
print("Your age - " + age) # prints name
print("Marks scored by you - " + marks) # prints marks.
print("Thanks for viewing this code") # The thank you message.