Questions
Your objective is to write a well-documented simple program using classes, a loop, and nested ifs...

Your objective is to write a well-documented simple program using classes, a loop, and nested ifs to simulate an ATM using JAVA.

1. Create an ATM class with class variables name, pin, and balance, a constructor with parameters to assign values to the three instance variables, methods to get the name, pin, and balance, and methods to handle validated deposits and withdrawals ( deposit and withdrawal amounts cannot be negative, and withdrawal amount must not be greater than the existing balance).

2. In the ATMTest class, read the names, 4 digit pin numbers, and account balances of two customers into two instances of the ATM class. Display the two customers names, pins, and balances formatted.

3. Now that you have all your customers’ information start your ATM to accomplish the following within an infinite loop,

a). Display a welcome screen with your bank’s information and prompt for and read the customer entered pin.

b). Use a nested if to match the entered pin with one of the two customers’ pins. If the entered pin number matches that of one of the customers, then:

i. Welcome the customer by name and display the balance.

ii. Display option to 1. DEPOSIT, 2. WITHDRAW or 3. EXIT.

iii. If option 1 is selected, then use the instance deposit method to prompt for deposit amount, read, and add a valid deposit amount to the customer’s balance

iv. If option 2 is selected, then use the instance withdrawal method to subtract a valid withdrawal amount from the customers balance

v. If option 3 is selected, go to step a.

4. Should the entered pin number not match either of the two customers, notify the customer that the entered pin is not valid and go to step a.

5. Selection of the EXIT option must display welcome/login screen (step a).

6. Should an incorrect option be entered, notify the user and display the original welcome/login screen (step a).

Please lists the IDE you used for the project.

In: Computer Science

This question has been answered before. I need a new, slightly modified code for the following:...

This question has been answered before. I need a new, slightly modified code for the following:

A palindrome is a word that it reads the same left to right and right to left. For this programming assignment, you need to write a C++ program that does the following:

  • Request the user to enter a string.
  • Write a recursive function that will test the string to validate if it is a palindrome or not.
  • Respond back with an output saying if the original string was a palindrome or not.

Please provide new code along with screenshot of output.

In: Computer Science

Explain how Apple Inc. customers will place an order, how the order will be delivered and...

Explain how Apple Inc. customers will place an order, how the order will be delivered and how the process for complaints will be handled.

In: Computer Science

This question has been answered already however, I'd like some new examples. Task: In C#, create...

This question has been answered already however, I'd like some new examples.

Task: In C#, create a minimum of three try/catch statements that would handle potential input errors. Thank you.

In: Computer Science

Java questions. Please answer everything. It mean the world to me. Thank you very much Identify...

Java questions. Please answer everything. It mean the world to me. Thank you very much

  1. Identify the errors in the following code fragment:
    1: ArrayList<String> list = new ArrayList<String>();
    2: list.add( "Denver" );
    3: list.add( "Austin" );
    4: list.add( new java.util.Date() );
    5: String city = list.get( 0 );
    6: list.set( 2, "Dallas" );
    7: System.out.println( list.get(2) );
  2. Explain why the following code fragment displays [1, 3] rather than [2, 3].
    1: ArrayList<Integer> list = new ArrayList<Integer>();
    2: list.add(1);
    3: list.add(2);
    4: list.add(3);
    5: list.remove(1);
    6: System.out.println( list );
  3. Describe the difference between passing a parameter of a primitive type and passing a parameter of a reference type. Then show the output of the following program:
     1: class Test {
     2:     public static void main ( String [] args ) {
     3:         Count myCount = new Count();
     4:         int times = 0;
     5:         for ( int i = 0; i < 100; i++ )
     6:             increment( myCount, times );
     7:         System.out.println( "count is " + myCount.count );
     8:         System.out.println( "times is " + times );
     9:     }
    10:     public static void increment ( Count c, int times ) {
    11:         c.count++;
    12:         times++;
    13:     }
    14: }
    15: 
    16: class Count {
    17:     public int count;
    18:     public Count ( int c ) {
    19:         count = c;
    20:     }
    21:     public Count () {
    22:         count = 1;
    23:     }
    24: }
  4. What is wrong in the following code?
    1: public class Test {
    2:    public static void main ( String [] args ) {
    3:       java.util.Date[] dates = new java.util.Date[10];
    4:       System.out.println( dates[0] );
    5:       System.out.println( dates[0].toString() );
    6:    }
    7: }
  5. If a class contains only private data fields and no “set” methods, is the class considered to be immutable?
  6. If a class contains only data fields that are both private and primitive, and no “set” methods, is the class considered to be immutable?
  7. What is wrong in the following code?
     1: public class C {
     2:     private int p;
     3: 
     4:     public C () {
     5:         System.out.println( "C's no-arg constructor invoked" );
     6:         this(0);
     7:     }
     8: 
     9:     public C ( int p ) {
    10:         p = p;
    11:     }
    12: 
    13:     public void setP ( int p ) {
    14:         p = p;
    15:     }
    16: }
  8. What is wrong in the following code?
    1: public class Test {
    2:     private int id;
    3:     public void m1 () {
    4:         this.id = 45;
    5:     }
    6:     public void m2 () {
    7:         Test.id = 45;
    8:     }
    9: }

In: Computer Science

The code must work on PEP/9, it shouldn't be too complicated and long Take the following...

The code must work on PEP/9, it shouldn't be too complicated and long

Take the following C++ program and translate it into Pep/9 assembly language

#include

using namespace std;

int age;

char first, last;

int main() {

   cin >> age;

   cin >> first >> last;

   cout << "Your age " << age << endl;

   cout << "Initials " << first << last << endl;

   if (age >= 30)

       cout << “Cannot trust\n”;

   return 0;

}

In: Computer Science

write a program in python that insert a number in the middle of an array. Assume...

write a program in python that insert a number in the middle of an array. Assume that the length of an array is even. For instance, is a=(1,4,7,9) and num=100, then really=(1,4,100,7,9)

In: Computer Science

Principles of Information Security Using nothing less than 1000 words Identify and explain in details the...

Principles of Information Security

Using nothing less than 1000 words Identify and explain in details the six components of an information system. Which are most directly affected by the study of computer security? Which are most associated with its study?

In: Computer Science

1 TB = x MB, where x is: Select one: a. 1024 b. 1,000,000 c. 1024...

1 TB = x MB, where x is:

Select one:

a. 1024

b. 1,000,000

c. 1024 * 1024

d. 1024 * 1024 * 1024

In: Computer Science

0. Introduction. In this lab assignment, you will extend some simple Java classes that represent plane...

0. Introduction.

In this lab assignment, you will extend some simple Java classes that represent plane figures from elementary geometry. The object of this assignment is not to do anything useful, but rather to demonstrate how methods can be inherited by extending classes.

1. Theory.

A polygon is a closed plane figure with three or more sides, all of which are line segments. The perimeter of a polygon is the sum of the lengths of its sides. A rectangle is a polygon with exactly four sides that meet at 90° angles. Like a polygon, it has a perimeter. It also has an area, the product of its base and height. A square is a rectangle whose sides are all the same length. Like a rectangle, it has a perimeter and an area.
      Polygons, rectangles, and squares make up an is-a hierarchy. The hierarchy gets its name because a square is-a rectangle, and a rectangle is-a polygon. Is-a hierarchies can be easily modeled by Java classes using the extends keyword.

2. Implementation.

The following is the source code for a Java class whose instances represent polygons. The file Polygon.java on Canvas contains a copy of this source code. You will need it to complete the laboratory assignment.

class Polygon
{
  private int[] sideLengths;

  public Polygon(int sides, int ... lengths)
  {
    int index = 0;
    sideLengths = new int[sides];
    for (int length: lengths)
    {
      sideLengths[index] = length;
      index += 1;
    }
  }

  public int side(int number)
  {
    return sideLengths[number];
  }

  public int perimeter()
  {
    int total = 0;
    for (int index = 0; index < sideLengths.length; index += 1)
    {
      total += side(index);
    }
    return total;
  }
}

The class Polygon uses a private array called sideLengths to store the lengths of a polygon’s sides. The array’s length, sideLengths.length, is the number of sides that the polygon has. The class Polygon also has a has a public constructor and two public methods. To keep things simple, they do not check their arguments for correctness, as they would if Polygon was part of a real program.
      The constructor takes four or more arguments and returns an instance of Polygon that represents a polygon. The first argument is the number of sides that the polygon has. The remaining arguments are the lengths of those sides. For example, the Java statement:

Polygon triangle = new Polygon(3, 3, 4, 5);

declares the variable triangle and sets it to an instance of Polygon that represents a triangle (because the first argument says it has 3 sides). The lengths of the triangle’s sides are 3, 4, and 5.
      The three dots ‘...’ in the constructor mean that it can take zero or more extra integer arguments after its first argument. The for-loop with the colon visits the extra arguments one at a time. Don’t worry if those parts of Java are unfamiliar. You don’t have to know how the constructor works, only how to call it.
      The method side returns the length of a polygon’s side. Sides are numbered starting from 0. For example, the expression triangle.side(0) returns 3, the expression triangle.side(1) returns 4, and the expression triangle.side(2) returns 5.
      The method perimeter returns a polygon’s perimeter, the sum of the lengths of its sides. For example, the expression triangle.perimeter() returns 3 + 4 + 5 = 12.
      For this assignment, you must write a class called Rectangle. As its name suggests, each instance of Rectangle must represent a rectangle. Along with a constructor, Rectangle must provide two methods, called area and perimeter. The method area must return the integer area of the rectangle, and the method perimeter must return the integer perimeter of the rectangle.
      You must also write another class, called Square. As its name suggests, each instance of Square must represent a square. Along with a constructor, Square must provide two methods, called area and perimeter. The method area must return the integer area of the square, and the method perimeter must return the integer perimeter of the square.
      The following driver program shows examples of how the constructors and methods of Rectangle and Square must work.

class Shapes
{
  public static void main(String[] args)
  {
    Rectangle wreck = new Rectangle(3, 5);  //  Make a 3 × 5 rectangle.
    System.out.println(wreck.area());       //  Print its area, 15.
    System.out.println(wreck.perimeter());  //  Print its perimeter, 16.

    Square nerd = new Square(7);            //  Make a 7 × 7 square.
    System.out.println(nerd.area());        //  Print its area, 49.
    System.out.println(nerd.perimeter()     //  Print its perimeter, 28.
  }
}

Your classes Rectangle and Square must use the extends keyword, so they will inherit methods from other classes. Also, each class must inherit as many of its methods as possible from those other classes. YOU WILL LOSE POINTS FOR DEFINING A METHOD INSIDE A CLASS, IF IT COULD HAVE BEEN INHERITED FROM ANOTHER CLASS!
      Here’s a hint about how to write the constructors for Rectangle and Square. Suppose that a class Triangle extends the class Polygon. Then Polygon is the superclass of Triangle. The keyword super can be used to call the constructor that belongs to a superclass. For example, Triangle’s constructor, which takes the lengths of a triangle’s three sides, might look like this.

public Triangle(int a, int b, int c)
{
  super(3, a, b, c);
}

It uses Polygon’s constructor to make a polygon with 3 sides, whose lengths are a, b, and c. If super is used in this way, then it must be the first statement in the constructor. You don’t have to write Triangle—this was only an example!

3. Deliverables.

The file tests6.java contains a driver class whose a main method performs 12 public tests, worth 1 point each. Each public test is a call to println, along with a comment that shows what it must print. To grade your work, the TA’s will run the public tests using your Rectangle and Square classes. If a public test behaves exactly as it should, then you will receive 1 point for it.
      In addition, the TA’s will do 5 private tests on your Rectangle and Square classes. You will not be told what the private tests are, but they are worth 2 points each, and they determine if Rectangle and Square have inherited as many methods as possible. The TA’s will do the same private tests for all students, and these tests will be made public only after all the work for this lab has been graded.
      Your score for this lab is the sum of the points you get for the public tests, and the points you get for the private tests, for a maximum of 22 points. Here is what you must turn in.

  1. Source code for the class Rectangle. Its instances must provide the methods side, area and perimeter. These methods are not necessarily defined in Rectangle: some or all may be inherited.

  2. Source code for the class Square. Its instances must provide the methods side, area and perimeter. These methods are not necessarily defined in Square: some or all may be inherited.

In: Computer Science

Prompt the user to enter a string of their choosing. Store the text in a string....

Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt)

Ex:

Enter a sample text:
we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!

You entered: we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!


(2) Implement a print_menu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option and the sample text string (which can be edited inside the print_menu() function). Each option is represented by a single character.

If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement the Quit menu option before implementing other options. Call print_menu() in the main section of your code. Continue to call print_menu() until the user enters q to Quit. (3 pts)

Ex:

MENU
c - Number of non-whitespace characters
w - Number of words
f - Fix capitalization
r - Replace punctuation
s - Shorten spaces
q - Quit

Choose an option:


(3) Implement the get_num_of_non_WS_characters() function. get_num_of_non_WS_characters() has a string parameter and returns the number of characters in the string, excluding all whitespace. Call get_num_of_non_WS_characters() in the print_menu() function. (4 pts)

Ex:

Number of non-whitespace characters: 181


(4) Implement the get_num_of_words() function. get_num_of_words() has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call get_num_of_words() in the print_menu() function. (3 pts)

Ex:

Number of words: 35


(5) Implement the fix_capitalization() function. fix_capitalization() has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. fix_capitalization() also returns the number of letters that have been capitalized. Call fix_capitalization() in the print_menu() function, and then output the the edited string followed by the number of letters capitalized. Hint 1: Look up and use Python functions .islower() and .upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string. (3 pts)

Ex:

Number of letters capitalized: 3
Edited text: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!


(6) Implement the replace_punctuation() function. replace_punctuation() has a string parameter and two keyword argument parameters exclamation_count and semicolon_count. replace_punctuation() updates the string by replacing each exclamation point (!) character with a period (.) and each semicolon (;) character with a comma (,). replace_punctuation() also counts the number of times each character is replaced and outputs those counts. Lastly, replace_punctuation() returns the updated string. Call replace_punctuation() in the print_menu() function, and then output the edited string. (3 pts)

Ex:

Punctuation replaced
exclamation_count: 1
semicolon_count: 2
Edited text: we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  nothing ends here,  our hopes and our journeys continue.


(7) Implement the shorten_space() function. shorten_space() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shorten_space() returns the string. Call shorten_space() in the print_menu() function, and then output the edited string. Hint: Look up and use Python function .isspace(). (3 pt)

Ex:

Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!

In: Computer Science

Identifying appropriate data mining technique(s) for reaching goals on : innovation of intelligence transportation system nowadays...

Identifying appropriate data mining technique(s) for reaching goals on : innovation of intelligence transportation system nowadays .

In: Computer Science

How to separate 2000H of external RAM? Sent the high 4 bits to the low 4...

How to separate 2000H of external RAM? Sent the high 4 bits to the low 4 bits of 2001H, and the low 4 bits are sent to the low 4 bits of 2002H. Clear the high 4 bits of 2001H and 2002H.

the answer in C program please

In: Computer Science

Summary In this lab, you write a while loop that uses a sentinel value to control...

Summary In this lab, you write a while loop that uses a sentinel value to control a loop in a C++ program that has been provided. You also write the statements that make up the body of the loop. The source code file already contains the necessary variable declarations and output statements. Each theater patron enters a value from 0 to 4 indicating the number of stars the patron awards to the Guide’s featured movie of the week. The program executes continuously until the theater manager enters a negative number to quit. At the end of the program, you should display the average star rating for the movie. Instructions Ensure the source code file named MovieGuide.cpp is open in your code editor. Write the while loop using a sentinel value to control the loop, and write the statements that make up the body of the loop. The output statements within the loop have already been written for you. Ensure you include the calculations to compute the average rating. Execute the program by clicking the Run button. Input the following: 0, 3, 4, 4, 1, 1, 2, -1 Ensure the average output is correct.

this is the prewritten code:

// MovieGuide.cpp - This program allows each theater patron to enter a value from 0 to 4

// indicating the number of stars that the patron awards to the Guide's featured movie of the

// week. The program executes continuously until the theater manager enters a negative number to

// quit. At the end of the program, the average star rating for the movie is displayed.  

#include <iostream>

#include <string>

using namespace std;

int main()

{

    

   // Declare and initialize variables.

   double numStars;            // star rating.

   double averageStars;    // average star rating.

   double totalStars = 0;    // total of star ratings.

   int numPatrons = 0;           // keep track of number of patrons

      

  

   // This is the work done in the housekeeping() function

   // Get input.

   cout << "Enter rating for featured movie: ";

   cin >> numStars;

        

   // This is the work done in the detailLoop() function

   // Write while loop here    

   // This is the work done in the endOfJob() function

   cout << "Average Star Value: " << averageStars << endl;

   return 0;

} // End of main()

In: Computer Science

Please, write this code in c++. Using iostream and cstring library. Write a function that will...

Please, write this code in c++. Using iostream and cstring library.

Write a function that will delete all words in the given text that meets more that one time. Also note than WORD is sequence of letters sepereated by whitespace.

Note. The program have to use pointer.

Input: First line contains one line that is not longer than 1000 symbols with whitespaces. Each word is not longer than 30 symbols.

Output: Formatted text.

example:

input: Can you can the can with can ?

output: Can you can the with ?

In: Computer Science