HTML
7.20
A palindrome is a number or a text phrase that reads the same backward and forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a script that reads in a five-digit integer and determines whether it’s a palindrome. If the number is not five digits long, display an alert dialog indicating the problem to the user. Allow the user to enter a new value after dismissing the alert dialog. [Hint: It’s possible to do this exercise with the techniques learned in this chapter. You’ll need to use both division and remainder operations to “pick off” each digit.]
In: Computer Science
In: Computer Science
Create a program that asks the user for two positive integers. If the user's input for either integer is not positive (less than or equal to 0), re-prompt the user until a positive integer is input. You may assume that all inputs will be integers.
Print out a list, ascending from 1, of all divisors common to both integers. Then, print out a message stating whether or not the numbers are "relatively prime" numbers. Two positive integers are considered relatively prime if, and only if, the only common divisor they have is 1.
For example, if the user inputs 8 and 12 the output should be:
Common divisors of 8 and 12:
1
2
4
8 and 12 are not relatively prime.
If the user inputs 8 and 9, on the other hand, the output should be:
Common divisors of 8 and 9:
1
8 and 9 are relatively prime.
Starter Code:-
import java.util.Scanner;
public class RelativelyPrime {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in); //Scanner to get user
input
//TODO
//Complete the program
}
}
In: Computer Science
The purpose of this assignment is to build the business calculator using supporting files built inTopics 4 and 5.Create a Java application file named RPN.java containing a main method by using the ForthStack.java and associated files from Topic 5.The application should have one text box for numeric data entry, one text box for numeric display, one text box for error display, and buttons labeled "+", "-", "*", "/","dup", "2dup", "clr", "pop" and "push." The actions of the controls should be as follows.oThe text box for numeric display should display the top element of the stack, or blank if the stack is empty.oThe text box for numeric data entry should allow the user to type in a valid numeric value.oThe text box for error display should display an error message from the previous operation (if any), or be blank if the last operation was successful.oThe buttons labeled "+", "-", "*", "/", "dup", "2dup", "clr", and pop should invoke the corresponding methods in ForthStack; "pop" should remove and discard the top item on the stack, and "push" should push the numeric value in the numeric data entry box onto the stack and clear the numeric data entry box.oAll button operations should update the display of the top of the stack.The size of the stack used should be four, no more or less, in order to standardize testing.After thoroughly testing the program, submit the AbstractStack.java, ArrayStack.java,Forth.java, ForthStack.java, TestForthStack.java, and RPN.java
STACK CODE:
ArrayStack.java
import java.util.Arrays;
public class ArrayStack extends AbstractStack {
//Attributes
private double[] array;
private int size;
private int num;
//Default constructor
public ArrayStack() {
array = new double[3];
size = 3;
num = 0;
}
//Parametrized Constructor
public ArrayStack(int a){
array = new double[a];
size = a;
num = 0;
}
//Insert a new element
public void push(double a){
if (num < size) {
array[num] = a;
num++;
System.out.println("Success");
}
else {
throw new ArrayIndexOutOfBoundsException("Failure! Stack is
full");
}
}
//Take out last inserted value
public double pop(){
if (num > 0){
num--;
return array[num];
}
else {
throw new ArrayIndexOutOfBoundsException("Stack is empty");
}
}
//Check stack empty or not
public boolean isEmpty(){
return (num == 0);
}
//Get top element from stack
public double peek() {
return peek(num-1);
}
//Get specified index element
public double peek(int n){
try
{
if (num > 0){
if (n < 0 || n >= num)
return -1;
else
return array[n];
}
else{
System.out.println("Stack is empty");
return -1;
}
}catch(Exception e ){
e.printStackTrace();
}
return 0;
}
//Number of elements in stack
public int count(){
return num;
}
public void clear() {
size=0;;
num=0;
}
}
public class FourthStack extends ArrayStack implements
Fourth{
//Parameterized constructor
public FourthStack(int sz) {
super(sz);
}
@Override
//Pop 2 elements from stack and add values
//Push into stack
public void add() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()+super.pop());
}
}
@Override
//Pop 2 elements from stack and subtract second from first
//Push into stack
public void sub() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()-super.pop());
}
}
@Override
//Pop 2 elements from stack and multiply values
//Push into stack
public void mul() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()*super.pop());
}
}
@Override
//Pop 2 elements from stack and divide second from first
values
//Push into stack
public void div() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()/super.pop());
}
}
@Override
//peek an element and make duplicate
//Push into stack
public void dup() {
if(super.count()<1) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.peek());
}
}
//Peek 2 elements from stack and make their duplicate
//Push into stack in same order
@Override
public void twoDup() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
double first=super.peek();
double second=super.peek(super.count()-2);
super.push(second);
super.push(first);
}
}
}
import java.util.Scanner;
/**
* Test implemented functions
* @author deept
*
*/
public class TestFourthStack {
public static void main(String [] args){
//Variables for input
int choice;
int pek;
double val,poped;
boolean empty;
//Keyboard read
Scanner sc =new Scanner(System.in);
FourthStack as = new FourthStack(20);
//Loop until exit
while(true){
//User choices
System.out.println("1. Enter a Value in stack");
System.out.println("2. Pop a Value");
System.out.println("3. Check If array is Empty");
System.out.println("4. Peek Function");
System.out.println("5. Clear Stack");
System.out.println("6. Add Function");
System.out.println("7. Sub Function");
System.out.println("8. Mul Function");
System.out.println("9. Div Function");
System.out.println("10. Dup Function");
System.out.println("11. TwoDup Function");
System.out.println("0. Exit\n");
choice = sc.nextInt();
//Execute each choice
switch(choice){
case 1:
System.out.print("Enter a value To push : ");
val = sc.nextDouble();
as.push(val);
break;
case 2:
poped = as.pop();
System.out.println("Popped : "+poped);
break;
case 3:
empty = as.isEmpty();
System.out.println("Empty ? "+empty);
break;
case 4:
poped = as.peek();
if(poped != -1)
System.out.println("Peeked Value : "+poped);
else
System.out.println("Oops it was not a valid index this place is
empty");
break;
case 5:
as.clear();
break;
case 6:
as.add();
break;
case 7:
as.sub();
break;
case 8:
as.mul();
break;
case 9:
as.div();
break;
case 10:
as.dup();
break;
case 11:
as.twoDup();
break;
case 0:
System.exit(0);
}
}
}
}
/*
* Pure abstract class without implementation
*/
public abstract class AbstractStack {
public abstract void push(double item);
public abstract double pop();
public abstract boolean isEmpty();
public abstract double peek();
public abstract void clear();
}
/*
* Interface to generate sum additional functions using stack
*/
public interface Fourth {
public void add();
public void sub();
public void mul();
public void div();
public void dup();
public void twoDup();
}
I PROVIDED THE FIVE PREVIOUS STACKS THAT I USED ON MY PREVIOUS WORK... LET ME KNOW IF THERE'S ANYTHING ELSE
In: Computer Science
Fill in the blank for this common use of the for loop in processing each character of a string. for _____________________________________________________ { char ch = str.charAt(i); // process ch } |
Insert the missing statement in the following code fragment prompting the user to enter a positive number. double value; do { System.out.print("Please enter a positive number: "); value = in.nextDouble(); } _____________________________________ |
The following for loop is executed how many times? for (x = 0; x <= 10; x++) |
Consider the following for loop: for (i = 0; i < str.length(); i++) { ... } and the corresponding while loop: i = 0; while __________________________________ { . . . i++; } Fill in the blank for the while loop condition that is equivalent to the given for loop? |
Write a for loop that is equivalent to the given while loop. i = 1; while (i <= 5) { . . . i++; } |
In: Computer Science
1Write an SQL statement utilizing the WHERE, LIKE, and HAVING clauses that select gender, and the email addresses that belong to female users and have an email address that contains a number (0 to 9) within it. Create an alias for the resultant email column name and name it ‘Email Addresses Female With Numbers’
IPV4 (Internet Protocol Version 4) addresses utilize a notation known as the dotted-quad notation. Quad because an IPV4 address is actually a series of 4 numbers separated by a dot (hence dotted quad). Each one of the numbers has a range of 0-255. For example 255.0.65.23 is a valid IPV4 address, and so is 2.2.2.2. However, 2682.586.549.365 is NOT a valid IPV4 address (thank me later for not using IPV6 addresses for this – Google IPV6 and you will see what I mean).
Write an SQL insert statement that will insert 4 rows with invalid IPV4 addresses.
Write an SQL statement that will find all the rows with invalid IPV4 addresses.
To do this you will need to utilize regular expressions. This is the research
component of the lab.
Regular expression documentation:
https://dev.mysql.com/doc/refman/5.6/en/regexp.html
You can look up the regular expression, you do not have to write one from scratch, but it is always a good thing to look up the syntax of regular expressions to be able to understand them.
You need to validate that there are 4 numbers separated by dots each with a length of 1-3 (e.g., 999.999.999.999 is considered a valid IP address in your regular expression even though it is not in reality). Validating that there are 4 numbers separated by dots each with a length of 1-3 AND are less than 256 is a little complicated, but I encourage you to take on the challenge.
By now you should see how the query from b can be created in a much cleaner fashion.
In: Computer Science
given pair (a,b) after each unit of time pair (a,b) get changed to (b-a,b+a).you are given the initial value of pair and an integer n and you to print the value of pair at the nth unit of time.
input format:
1.First line:t donating the number of test cases
2.Next t lines:three space-seperated integer a,b and n
output format :
for each test case ,print two integers (mod 10^9 +7) per
line denoting the value of the pair at the n th unit time.
constrains:
1<t< 10^6
0< a<b<10^9
1<n<10^5
sample input :
5
1 3 5
2 3 9
sample output
4 12
32 48
81920 131072
In: Computer Science
The purpose of this problem is to gain familiarity with stacks and queues. You have three jugs that can hold c1, c2, and c3 liters of water, respectively. Initially, jug 1 is full and the other two jugs are empty. You can repeat the following procedure any number of times: Choose two of the jugs and pour the contents of one into the other until either the first is empty or the second is full. Your goal is to end up with exactly d liters in one of the jugs. Make a program called WaterTransfer.java to determine the transfers required to reach the goal. The input is a single line containing four integers between 2 and 100 (inclusive) representing c1, c2, c3, and d. The output is a minimal sequence of jug contents, starting with the initial contents and ending with one of the jugs containing d liters. Each line of the output should consist of 3 integers separated by spaces. If no solution exists, then your program should produce no output.
Good test case: 10 5 3 4 ; from movie ”Die hard: with a vengeance”; seehttps://www.youtube.com/watch?v=6cAbgAaEOVE
For example, if the input is 20 5 3 4t hen a valid output is
20 0 0
15 5 0
15 2 3
18 2 0
18 0 2
13 5 2
13 4 3
There may be other solutions, but none with fewer transfers (6) than this one. (this code should probably use queues)
In: Computer Science
T/F: A function may not execute every line of code in the function if it returns a value to the user before getting to the remaining lines.
|
In: Computer Science
Design a Java Animal class (assuming in Animal.java file) and a sub class of Animal named Cat (assuming in Cat.java file).
The Animal class has the following protected instance variables:
boolean vegetarian, String eatings, int numOfLegs and the following public instance methods:
constructor without parameters: initialize all of the instance variables to some default values
constructor with parameters: initialize all of the instance variables to the arguments
SetAnimal: assign arguments to all of the instance variables
Three “Get” methods which retrieve the respective values of the instance variables
toString: Returns the animal’s vegetarian, eatings and numOfLegs information as a string
The Cat class has the following private instance variable:
String color and the following public instance methods:
constructor without parameters: initialize all of the instance variables to some default values, including its super class - Animal’s instance variables
constructor with parameters: initialize all of the instance variables to the arguments, including its super class Animal’s instance variables
SetColor: assign its instance variable to the argument
GetColor: retrieve the color value
overrided toString: Returns the cat’s vegetarian, eatings, numOfLegs and color information as a string
Please write your complete Animal class, Cat class and a driver class as required below
a (35 pts) Write your complete Java code for the Animal class in Animal.java file
b (30 pts) Write your complete Java code for the Cat class in Cat.java file
b (35 pts) Write your test Java class and its main method which will create two Cats instances: e1 and e2, e1 is created with the default constructor, e2 is created with the explicit value constructor. Then update e1 to reset its vegetarian, eatings, numOfLegs and color. Output both cats’ detailed information. The above test Java class should be written in a Java file named testAnimal.java.
In: Computer Science
You connected your PC to a projector or printer, which is located 20 m away and transmitted a signal x(t) from the PC to the receiver through USB cable. State and briefly explain three impairments the signal x(t) may likely experience as it propagates through the transmission channel
In: Computer Science
#include<iostream>
using namespace std;
const int NUM = 20;
int main() {
// write code to Declare an integer array of size 20 and assign the array with 20 randomly generated integers in the range [1, 100].
// Shuffle the data in the array so that all numbers smaller than 50 are put before the numbers greater or equal to 50. Note you are not allowed to create any other arrays in the program.
// Write code to print out the shuffled array.
return 0;
}
Please Use C++ to solve
In: Computer Science
C++ Data Structures:
Use Huffman coding to encode text in given file
(Pride_and_Prejudice.txt).
TO_DO:
Define a struct for Huffman tree node. This struct contains links to left/right child nodes, a character, and its frequency.Define a function for file reading operation. This function should take in a filename (string type) as parameter and return a proper data structure object that contains characters and their frequencies that will be used to generate Huffman tree nodes.The construction of Huffman tree requires taking two nodes with smallest frequencies. Select a proper data structure to support this operation. Note this data structure object could be different to the object from step 2.
Design a function that takes in the root of Huffman coding tree, prints, and returns the encoding scheme in a data structure object.Design a function that takes in the encoding scheme and filename (string type), output encoded content (bit-string) to a file named pride.huff
Pride_and_Prejudice.txt:
Chapter 1
It is a truth universally acknowledged, that a single
man in possession of a good fortune, must be in want of a wife.
However little known the feelings or views of such a man may be on
his first entering a neighbourhood, this truth is so well fixed in
the minds of the surrounding families, that he is considered the
rightful property of some one or other of their daughters. “My dear
Mr. Bennet,” said his lady to him one day, “have you heard that
Netherfield Park is let at last?” Mr. Bennet replied that he had
not. “But it is,” returned she; “for Mrs. Long has just been here,
and she told me all about it.” Mr. Bennet made no answer. “Do you
not want to know who has taken it?” cried his wife impatiently.
“You want to tell me, and I have no objection to hearing it.” This
was invitation enough. “Why, my dear, you must know, Mrs. Long says
that Netherfield is taken by a young man of large fortune from the
north of England; that he came down on Monday in a chaise and four
to see the place, and was so much delighted with it, that he agreed
with Mr. Morris immediately; that he is to take possession before
Michaelmas, and some of his servants are to be in the house by the
end of next week.” “What is his name?” “Bingley.” “Is he married or
single?” “Oh! Single, my dear, to be sure! A single man of large
fortune; four or five thousand a year. What a fine thing for our
girls!” “How so? How can it affect them?” “My dear Mr. Bennet,”
replied his wife, “how can you be so tiresome! You must know that I
am thinking of his marrying one of them.” “Is that his design in
settling here?” “Design! Nonsense, how can you talk so! But it is
very likely that he may fall in love with one of them, and
therefore you must visit him as soon as he comes.” “I see no
occasion for that. You and the girls may go, or you may send them
by themselves, which perhaps will be still better, for as you are
as handsome as any of them, Mr. Bingley may like you the best of
the party.” “My dear, you flatter me. I certainly have had my share
of beauty, but I do not pretend to be anything extraordinary now.
When a woman has five grown-up daughters, she ought to give over
thinking of her own beauty.” “In such cases, a woman has not often
much beauty to think of.” “But, my dear, you must indeed go and see
Mr. Bingley when he comes into the neighbourhood.” “It is more than
I engage for, I assure you.” “But consider your daughters. Only
think what an establishment it would be for one of them. Sir
William and Lady Lucas are determined to go, merely on that
account, for in general, you know, they visit no newcomers. Indeed
you must go, for it will be impossible for us to visit him if you
do not.” “You are over-scrupulous, surely. I dare say Mr. Bingley
will be very glad to see you; and I will send a few lines by you to
assure him of my hearty consent to his marrying whichever he
chooses of the girls; though I must throw in a good word for my
little Lizzy.” “I desire you will do no such thing. Lizzy is not a
bit better than the others; and I am sure she is not half so
handsome as Jane, nor half so good-humoured as Lydia. But you are
always giving her the preference.” “They have none of them much to
recommend them,” replied he; “they are all silly and ignorant like
other girls; but Lizzy has something more of quickness than her
sisters.” “Mr. Bennet, how can you abuse your own children in such
a way? You take delight in vexing me. You have no compassion for my
poor nerves.” “You mistake me, my dear. I have a high respect for
your nerves. They are my old friends. I have heard you mention them
with consideration these last twenty years at least.” “Ah, you do
not know what I suffer.” “But I hope you will get over it, and live
to see many young men of four thousand a year come into the
neighbourhood.” “It will be no use to us, if twenty such should
come, since you will not visit them.” “Depend upon it, my dear,
that when there are twenty, I will visit them all.” Mr. Bennet was
so odd a mixture of quick parts, sarcastic humour, reserve, and
caprice, that the experience of three-and-twenty years had been
insufficient to make his wife understand his character. Her mind
was less difficult to develop. She was a woman of mean
understanding, little information, and uncertain temper. When she
was discontented, she fancied herself nervous. The business of her
life was to get her daughters married; its solace was visiting and
news. Chapter 2 Mr. Bennet was among the earliest of those who
waited on Mr. Bingley. He had always intended to visit him, though
to the last always assuring his wife that he should not go; and
till the evening after the visit was paid she had no knowledge of
it. It was then disclosed in the following manner. Observing his
second daughter employed in trimming a hat, he suddenly addressed
her with: “I hope Mr. Bingley will like it, Lizzy.” “We are not in
a way to know what Mr. Bingley likes,” said her mother resentfully,
“since we are not to visit.” “But you forget, mamma,” said
Elizabeth, “that we shall meet him at the assemblies, and that Mrs.
Long promised to introduce him.” “I do not believe Mrs. Long will
do any such thing. She has two nieces of her own. She is a selfish,
hypocritical woman, and I have no opinion of her.” “No more have
I,” said Mr. Bennet; “and I am glad to find that you do not depend
on her serving you.” Mrs. Bennet deigned not to make any reply,
but, unable to contain herself, began scolding one of her
daughters. “Don’t keep coughing so, Kitty, for Heaven’s sake! Have
a little compassion on my nerves. You tear them to pieces.” “Kitty
has no discretion in her coughs,” said her father; “she times them
ill.” “I do not cough for my own amusement,” replied Kitty
fretfully. “When is your next ball to be, Lizzy?” “To-morrow
fortnight.” “Aye, so it is,” cried her mother, “and Mrs. Long does
not come back till the day before; so it will be impossible for her
to introduce him, for she will not know him herself.” “Then, my
dear, you may have the advantage of your friend, and introduce Mr.
Bingley to her.” “Impossible, Mr. Bennet, impossible, when I am not
acquainted with him myself; how can you be so teasing?” “I honour
your circumspection. A fortnight’s acquaintance is certainly very
little. One cannot know what a man really is by the end of a
fortnight. But if we do not venture somebody else will; and after
all, Mrs. Long and her nieces must stand their chance; and,
therefore, as she will think it an act of kindness, if you decline
the office, I will take it on myself.” The girls stared at their
father. Mrs. Bennet said only, “Nonsense, nonsense!” “What can be
the meaning of that emphatic exclamation?” cried he. “Do you
consider the forms of introduction, and the stress that is laid on
them, as nonsense? I cannot quite agree with you there. What say
you, Mary? For you are a young lady of deep reflection, I know, and
read great books and make extracts.” Mary wished to say something
sensible, but knew not how. “While Mary is adjusting her ideas,” he
continued, “let us return to Mr. Bingley.” “I am sick of Mr.
Bingley,” cried his wife. “I am sorry to hear that; but why did not
you tell me that before? If I had known as much this morning I
certainly would not have called on him. It is very unlucky; but as
I have actually paid the visit, we cannot escape the acquaintance
now.” The astonishment of the ladies was just what he wished; that
of Mrs. Bennet perhaps surpassing the rest; though, when the first
tumult of joy was over, she began to declare that it was what she
had expected all the while. “How good it was in you, my dear Mr.
Bennet! But I knew I should persuade you at last. I was sure you
loved your girls too well to neglect such an acquaintance. Well,
how pleased I am! and it is such a good joke, too, that you should
have gone this morning and never said a word about it till now.”
“Now, Kitty, you may cough as much as you choose,” said Mr. Bennet;
and, as he spoke, he left the room, fatigued with the raptures of
his wife. “What an excellent father you have, girls!” said she,
when the door was shut. “I do not know how you will ever make him
amends for his kindness; or me, either, for that matter. At our
time of life it is not so pleasant, I can tell you, to be making
new acquaintances every day; but for your sakes, we would do
anything. Lydia, my love, though you are the youngest, I dare say
Mr. Bingley will dance with you at the next ball.” “Oh!” said Lydia
stoutly, “I am not afraid; for though I am the youngest, I’m the
tallest.” The rest of the evening was spent in conjecturing how
soon he would return Mr. Bennet’s visit, and determining when they
should ask him to dinner. Chapter 3 Not all that Mrs. Bennet,
however, with the assistance of her five daughters, could ask on
the subject, was sufficient to draw from her husband any
satisfactory description of Mr. Bingley. They attacked him in
various ways—with barefaced questions, ingenious suppositions, and
distant surmises; but he eluded the skill of them all, and they
were at last obliged to accept the second-hand intelligence of
their neighbour, Lady Lucas. Her report was highly favourable. Sir
William had been delighted with him. He was quite young,
wonderfully handsome, extremely agreeable, and, to crown the whole,
he meant to be at the next assembly with a large party. Nothing
could be more delightful! To be fond of dancing was a certain step
towards falling in love; and very lively hopes of Mr. Bingley’s
heart were entertained. “If I can but see one of my daughters
happily settled at Netherfield,” said Mrs. Bennet to her husband,
“and all the others equally well married, I shall have nothing to
wish for.” In a few days Mr. Bingley returned Mr. Bennet’s visit,
and sat about ten minutes with him in his library. He had
entertained hopes of being admitted to a sight of the young ladies,
of whose beauty he had heard much; but he saw only the father. The
ladies were somewhat more fortunate, for they had the advantage of
ascertaining from an upper window that he wore a blue coat, and
rode a black horse. An invitation to dinner was soon afterwards
dispatched; and already had Mrs. Bennet planned the courses that
were to do credit to her housekeeping, when an answer arrived which
deferred it all. Mr. Bingley was obliged to be in town the
following day, and, consequently, unable to accept the honour of
their invitation, etc. Mrs. Bennet was quite disconcerted. She
could not imagine what business he could have in town so soon after
his arrival in Hertfordshire; and she began to fear that he might
be always flying about from one place to another, and never settled
at Netherfield as he ought to be. Lady Lucas quieted her fears a
little by starting the idea of his being gone to London only to get
a large party for the ball; and a report soon followed that Mr.
Bingley was to bring twelve ladies and seven gentlemen with him to
the assembly. The girls grieved over such a number of ladies, but
were comforted the day before the ball by hearing, that instead of
twelve he brought only six with him from London—his five sisters
and a cousin. And when the party entered the assembly room it
consisted of only five altogether—Mr. Bingley, his two sisters, the
husband of the eldest, and another young man. Mr. Bingley was
good-looking and gentlemanlike; he had a pleasant countenance, and
easy, unaffected manners. His sisters were fine women, with an air
of decided fashion. His brother-in-law, Mr. Hurst, merely looked
the gentleman; but his friend Mr. Darcy soon drew the attention of
the room by his fine, tall person, handsome features, noble mien,
and the report which was in general circulation within five minutes
after his entrance, of his having ten thousand a year. The
gentlemen pronounced him to be a fine figure of a man, the ladies
declared he was much handsomer than Mr. Bingley, and he was looked
at with great admiration for about half the evening, till his
manners gave a disgust which turned the tide of his popularity; for
he was discovered to be proud; to be above his company, and above
being pleased; and not all his large estate in Derbyshire could
then save him from having a most forbidding, disagreeable
countenance, and being unworthy to be compared with his friend. Mr.
Bingley had soon made himself acquainted with all the principal
people in the room; he was lively and unreserved, danced every
dance, was angry that the ball closed so early, and talked of
giving one himself at Netherfield. Such amiable qualities must
speak for themselves. What a contrast between him and his friend!
Mr. Darcy danced only once with Mrs. Hurst and once with Miss
Bingley, declined being introduced to any other lady, and spent the
rest of the evening in walking about the room, speaking
occasionally to one of his own party. His character was decided. He
was the proudest, most disagreeable man in the world, and everybody
hoped that he would never come there again. Amongst the most
violent against him was Mrs. Bennet, whose dislike of his general
behaviour was sharpened into particular resentment by his having
slighted one of her daughters. Elizabeth Bennet had been obliged,
by the scarcity of gentlemen, to sit down for two dances; and
during part of that time, Mr. Darcy had been standing near enough
for her to hear a conversation between him and Mr. Bingley, who
came from the dance for a few minutes, to press his friend to join
it. “Come, Darcy,” said he, “I must have you dance. I hate to see
you standing about by yourself in this stupid manner. You had much
better dance.” “I certainly shall not. You know how I detest it,
unless I am particularly acquainted with my partner. At such an
assembly as this it would be insupportable. Your sisters are
engaged, and there is not another woman in the room whom it would
not be a punishment to me to stand up with.” “I would not be so
fastidious as you are,” cried Mr. Bingley, “for a kingdom! Upon my
honour, I never met with so many pleasant girls in my life as I
have this evening; and there are several of them you see uncommonly
pretty.” “You are dancing with the only handsome girl in the room,”
said Mr. Darcy, looking at the eldest Miss Bennet. “Oh! She is the
most beautiful creature I ever beheld! But there is one of her
sisters sitting down just behind you, who is very pretty, and I
dare say very agreeable. Do let me ask my partner to introduce
you.” “Which do you mean?” and turning round he looked for a moment
at Elizabeth, till catching her eye, he withdrew his own and coldly
said: “She is tolerable, but not handsome enough to tempt me; I am
in no humour at present to give consequence to young ladies who are
slighted by other men. You had better return to your partner and
enjoy her smiles, for you are wasting your time with me.” Mr.
Bingley followed his advice. Mr. Darcy walked off; and Elizabeth
remained with no very cordial feelings toward him. She told the
story, however, with great spirit among her friends; for she had a
lively, playful disposition, which delighted in anything
ridiculous. The evening altogether passed off pleasantly to the
whole family. Mrs. Bennet had seen her eldest daughter much admired
by the Netherfield party. Mr. Bingley had danced with her twice,
and she had been distinguished by his sisters. Jane was as much
gratified by this as her mother could be, though in a quieter way.
Elizabeth felt Jane’s pleasure. Mary had heard herself mentioned to
Miss Bingley as the most accomplished girl in the neighbourhood;
and Catherine and Lydia had been fortunate enough never to be
without partners, which was all that they had yet learnt to care
for at a ball. They returned, therefore, in good spirits to
Longbourn, the village where they lived, and of which they were the
principal inhabitants. They found Mr. Bennet still up. With a book
he was regardless of time; and on the present occasion he had a
good deal of curiosity as to the event of an evening which had
raised such splendid expectations. He had rather hoped that his
wife’s views on the stranger would be disappointed; but he soon
found out that he had a different story to hear. “Oh, my dear Mr.
Bennet,” as she entered the room, “we have had a most delightful
evening, a most excellent ball. I wish you had been there. Jane was
so admired, nothing could be like it. Everybody said how well she
looked; and Mr. Bingley thought her quite beautiful, and danced
with her twice! Only think of that, my dear; he actually danced
with her twice! and she was the only creature in the room that he
asked a second time. First of all, he asked Miss Lucas. I was so
vexed to see him stand up with her! But, however, he did not admire
her at all; indeed, nobody can, you know; and he seemed quite
struck with Jane as she was going down the dance. So he inquired
who she was, and got introduced, and asked her for the two next.
Then the two third he danced with Miss King, and the two fourth
with Maria Lucas, and the two fifth with Jane again, and the two
sixth with Lizzy, and the Boulanger—” “If he had had any compassion
for me,” cried her husband impatiently, “he would not have danced
half so much! For God’s sake, say no more of his partners. Oh that
he had sprained his ankle in the first dance!” “Oh! my dear, I am
quite delighted with him. He is so excessively handsome! And his
sisters are charming women. I never in my life saw anything more
elegant than their dresses. I dare say the lace upon Mrs. Hurst’s
gown—” Here she was interrupted again. Mr. Bennet protested against
any description of finery. She was therefore obliged to seek
another branch of the subject, and related, with much bitterness of
spirit and some exaggeration, the shocking rudeness of Mr. Darcy.
“But I can assure you,” she added, “that Lizzy does not lose much
by not suiting his fancy; for he is a most disagreeable, horrid
man, not at all worth pleasing. So high and so conceited that there
was no enduring him! He walked here, and he walked there, fancying
himself so very great! Not handsome enough to dance with! I wish
you had been there, my dear, to have given him one of your
set-downs. I quite detest the man.”
In: Computer Science
In C++
#include<iostream>
using namespace std;
const int NUM = 20;
int main() {
// write code to Declare an integer array of size 20 and assign the array with 20 randomly generated integers in the range [1, 100].
// Shuffle the data in the array so that all numbers smaller than 50 are put before the numbers greater or equal to 50. Note you are not allowed to create any other arrays in the program.
// Write code to print out the shuffled array.
return 0;
}
In: Computer Science
#include <iostream>
using namespace std;
void SortArrays (int a[], int b[], int c[], int size);
void printArray(int m[], int length);
const int NUM = 5;
int main()
{
int arrA[NUM] = {-2, 31, 43, 55, 67};
int arrB[NUM] = {-4, 9, 11, 17, 19};
int result[2*NUM];
SortArrays(arrA, arrB, result, NUM);
printArray(result, 2*NUM);
return 0;
}
void SortArrays (int a[], int b[], int c[], int size)
{
}
void printArray(int m[], int length)
{
for(int i = 0; i < length; i++)
cout<< m[i]<<" ";
cout<<endl;
}
Please Use C++
In: Computer Science