Program that prompts the user to enter his name. The program then greets the person with his name. but if the person name is “jack” an exception is thrown and he asked to quit the program
Answers
#include<iostream>using namespace std;int main(){ char name[10]; cout<<"Enter your name "; cin>>name; cout<<name;}
import java.util.Scanner; public class { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter your name: "); String name=input.nextLine(); System.out.print("Enter your age: "); int age=input.nextInt(); System.out.println("Your name is "+name+" and your age is "+age); } }
Learn More:-
Java is a simple language because its syntax is simple, clean, and easy to understand. ... For example, pointer and operator overloading are not used in Java. Object-Oriented: In Java, everything is in the form of the object. It means it has some data and behavior. A program must have at least one class and object.
Answer:
include<iostream>using namespace std;int main(){ char name[10]; cout<<"Enter your name "; cin>>name; cout<<name;}
import java.util.Scanner; public class { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter your name: "); String name=input.nextLine(); System.out.print("Enter your age: "); int age=input.nextInt(); System.out.println("Your name is "+name+" and your age is "+age); } }
Learn More:-
Java is a simple language because its syntax is simple, clean, and easy to understand. For example, pointer and operator overloading are not used in Java. Object-Oriented: In Java, everything is in the form of the object. It means it has some data and behavior. A program must have at least one class and object