Answer:
See explaination
Explanation:
EndOfSentenceException.java
//Create a class EndOfSentenceException that
//extends the Exception class.
class EndOfSentenceException extends Exception
{
//Construtor.
EndOfSentenceException(String str)
{
System.out.println(str);
}
}
CommaException.java
//Create a class CommaException that extends the class
//EndOfSentenceException.
class CommaException extends EndOfSentenceException
{
//Define the constructor of CommaException.
public CommaException(String str)
{
super(str);
}
}
PunctuationException.java
//Create a class PunctuationException that extends the class
//EndOfSentenceException.
class PunctuationException extends EndOfSentenceException
{
//Constructor.
public PunctuationException(String str)
{
super(str);
}
}
Driver.java
//Include the header file.
import java.util.Scanner;
//Define the class Driver to check the sentence.
public class Driver {
//Define the function to check the sentence exceptions.
public String checkSentence(String str)
throws EndOfSentenceException
{
//Check the sentence ends with full stop,
//exclamation mark
//and question mark.
if(!(str.endsWith(".")) && !(str.endsWith("!"))
&& !(str.endsWith("?")))
{
//Check the sentence is ending with comma.
if(str.endsWith(","))
{
//Throw the CommaException.
throw new CommaException("You can't "
+ "end a sentence in a comma.");
}
//Otherwise.
else
{
//Throw PunctuationException.
throw new PunctuationException("The sentence "
+ "does not end correctly.");
}
}
//If the above conditions fails then
//return this message to the main function.
return "The sentence ends correctly.";
}
//Define the main function.
public static void main(String[] args)
{
//Create an object of Scanner
Scanner object = new Scanner(System.in);
//Prompt the user to enter the sentence.
System.out.println("Enter the sentence:");
String sentence=object.nextLine();
//Begin the try block.
try {
//Call the Driver's check function.
System.out.println(new
Driver().checkSentence(sentence));
}
//The catch block to catch the exception.
catch (EndOfSentenceException e)
{}
}
}
Answer:
import java.util.*;
public class Country
{
public static void main(String args[])
{
char ch,temp;
int flag = 0;
String country;
ArrayList<String> countries = new ArrayList<String>();
Scanner sc = new Scanner(System.in);
do
{
System.out.println("enter the country you have visited:\t");
country = sc.next();
for(int i=0;i<countries.size();i++)
{
if(countries.get(i).equals(country))
{
System.out.println("you have already entered the country");
flag = 1;
break;
}
}
if(flag == 0)
{
countries.add(country);
flag = 0;
}
System.out.println("want to add another country(y/n):\t");
ch = sc.next().charAt(0);
}while(ch!='n');
Collections.sort(countries);
System.out.println("Countries you have visited:\t"+countries);
System.out.println("Total number of contries visited:"+countries.size());
}
}
Explanation:
Answer:
To edit an existing pattern, double-click the pattern in the pattern swatch, or select an object containing the pattern and choose Object > Pattern > Edit Pattern
Morality
Integrity
Honesty
Section B
Answer: Ethics
Explanation:
Ethics is the basic principle for the personal code. The code of the ethics is basically designed for outline the values in the organization with honesty and integrity.
The ethics is basically depend upon the principle of core value of the organization. The code of the ethics basically guide the core value in the organization and breaking the rule of ethics can also cause termination from the organization.
Morality, integrity and honesty are all the sub part of the ethics vale in the organization. Therefore, ethics is the correct option.
Answer:
#include<iostream>
using namespace std;
//create the function which add two number
void addTwoNumber(int num_1,int num_2)
{
int result = num_1 + num_2; //adding
cout<<"The output is:"<<result<<endl; //display on the screen
}
//main function
int main(){
//calling the function
addTwoNumber(3,6);
return 0;
}
Explanation:
First, include the library iostream for using the input/output instructions.
then, create the function which adds two numbers. Its return type is void, it means the function return nothing and the function takes two integer parameters.
then, use the addition operation '+' in the programming to add the numbers and store the result in the variable and display the result.
create the main function for testing the function.
call the function with two arguments 3 and 6.
then, the program copies the argument value into the define function parameters and then the program start executing the function.
Answer:
I can't give an answer if you don't tell me what you need help with
Explanation:
I can't give an answer if you don't tell me what you need help with
Answer:
(1) Carry flag (2) Overflow flag (3) Sign or negative Flag
Explanation:
Solution
(1) The carry flag : It refers to the adding or subtracting. a two registers has a borrow or carry bit
(2) The over flow flag: This flag specify that a sign bit has been modified during subtracting or adding of operations
(3) The sign flag: This is also called a negative sign flag is a single bit status in a register that specify whether the last mathematical operations generated a value to know if the most significant bit was set.