Question

In: Math

PYTHON: The following puzzle is known as The Big Cross-Out Swindle.“Beginning with the word ‘NAISNIENLGELTETWEORRSD,’ cross...

PYTHON: The following puzzle is known as The Big Cross-Out Swindle.“Beginning with the word ‘NAISNIENLGELTETWEORRSD,’ cross out nine letters in such a way that the remaining letters spell a single word”. Write a program that creates variables named startingWord, crossedOutLetters, andremainingLetters. The program should assign to startingWord the string given in the puzzle, assign tocrossedOutLetters a list containing every other letter of startingWordbeginning with the initial letter N, and assign to remainingLetters a list containing every other letter of startingWord beginning with the second letter, A. The program should then display the values of the three variables.

Solutions

Expert Solution

Program:

Sample output:

Code to copy:

/**Author.java**/

public class Author

{

     protected String name;

     protected String email;

     protected char gender;

     //Constructor

     public Author(String name, String email, char gender)

     {

          this.name = name;

          this.email = email;

          this.gender = gender;

     }

     //returns name

     public String getName()

     {

          return name;

     }

     //returns email

     public String getEmail()

     {

          return email;

     }

     //returns gender

     public char getGener()

     {

          return gender;

     }

     //sets email

     public void setEmail(String email)

     {

          this.email = email;

     }

     //returns a string with name and email

     public String toString()

     {

          return ( name + "(" + gender + ") at " + email);

     }

}

/**Book.java**/

public class Book

{

     private String name;

     private Author author;

     private double price;

     private int qtyInStock = 0;

     //Constructors

     public Book(String name, Author author,Double price)

     {

          this.author = author;

          this.name = name;

          this.price = price;

     }

     public Book(String name, Author author, double price, int qtyInStock)

     {

          this.name = name;

          this.author = author;

          this.price = price;

          this.qtyInStock = qtyInStock;

     }

     //returns name

     public String getName()

     {

          return name;

     }

     //returns auther

     public Author getAuthor()

     {

          return author;

     }

     //returns price of the book

     public double getPrice()

     {

          return price;

     }

     //Returns the quantity

     public int getQtyInStock()

     {

          return qtyInStock;

     }

     //sets the price of the book

     public void setPrice(double price)

     {

          this.price = price;

     }

     //sets the quantity

     public void setQtyInStock(int qtyInStock)

     {

          this.qtyInStock = qtyInStock;

     }

     //returns a string with name of the book and author details

     public String toString()

     {

          return (name + " by "+author);//Automatically author.toString() is called

     }

}

/**TestBook.java**/

public class TestBook

{

     public static void main(String[] args)

     {

          //Test Book class constructors

          Author oneAuthor=new Author("Tan Ah Teck","[email protected]",'m');

          Book book1=new Book("Introduction to authors",oneAuthor,15.50,300);

          System.out.println(book1.toString());

         

          Book book2=new Book("Introduction to authoring",new Author("James philip","[email protected]",'m'),15.50,330);

          System.out.println(book2.toString());

         

     }

}


Related Solutions

Perform a sentiment analysis of a big text file in python Extract each word from the...
Perform a sentiment analysis of a big text file in python Extract each word from the file, transform the words to lower case, and remove special characters from the words using code similar to the following line:w=w.replace(':','').replace('?','').replace(',','').replace('.','').replace('"','').replace('!','').replace('(','').replace(')','').replace('\'','').replace('\\','').replace('/','') Utilize the lists of positive words, found in positive.txt to perform a sentiment analysis on the file (count how many positive words there are in a file) positive.txt crisp crisper cure cure-all cushy cute cuteness danke danken daring ... file.txt ...has a new...
It is known that the mean time to solve the puzzle in healthy control children is...
It is known that the mean time to solve the puzzle in healthy control children is 60 seconds. Carry out the Wilcoxon signed-rank test on these data to test the null hypothesis that the mean time to solve the puzzle for children with NF1 is the same as for healthy controls. a) Calculate the value of the test statistic and give the approximate normal distribution of the test statistic under the null hypothesis. b) Calculate the p-value for the test...
Write a python program to finish a big-data processing task --- finding out most frequently used...
Write a python program to finish a big-data processing task --- finding out most frequently used words on Wikipedia pages. The execution of the program generates a list of distinct words used in the wikipedia pages and the number of occurrences of each word on these web pages. The words are sorted by the number of occurrences in ascending order. The following is a sample of output generated for 4 Wikipedia pages. 126 that 128 by 133 as 149 or...
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The...
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The words that need to be found are in the file 'WordList.txt'. There are 100 words to be found. You must find the location of the first and last letter of each word as well as the cardinal direction that describes the word's orientation. The location of first and last letters are to be described in terms of row and column, with indexing starting at...
Write a Python program to solve the 8-puzzle problem (and its natural generalizations) using the A*...
Write a Python program to solve the 8-puzzle problem (and its natural generalizations) using the A* search algorithm. The problem. The 8-puzzle problem is a puzzle invented and popularized by Noyes Palmer Chapman in the 1870s. It is played on a 3-by-3 grid with 8 square blocks labeled 1 through 8 and a blank square. Your goal is to rearrange the blocks so that they are in order, using as few moves as possible. You are permitted to slide blocks...
The A.T. Cross Company is well known for its Cross pens. The company recently reported the...
The A.T. Cross Company is well known for its Cross pens. The company recently reported the following amounts in its unadjusted trial balance as of December 31. Debits Credits   Accounts Receivable $ 30,691,000   Allowance for Doubtful Accounts $ 952,000   Sales Revenue 158,312,000 Required: 1. & 2. Prepare the adjusting journal entry required at December 31 for recording Bad Debt Expense. (If no entry is required for a transaction/event, select "No Journal Entry Required" in the first account field.) (i) Assume...
construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should...
construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should include two heuristic functions -misplaced tiles and calculation of manhattan distance. The code should work for all cases of puzzle.
I have a Python code that reads the text file, creates word list then calculates word...
I have a Python code that reads the text file, creates word list then calculates word frequency of each word. Please see below: #Open file f = open('example.txt', 'r') #list created with all words data=f.read().lower() list1=data.split() #empty dictionary d={} # Adding all elements of the list to a dictionary and assigning it's value as zero for i in set(list1):     d[i]=0 # checking and counting the values for i in list1:     for j in d.keys():        if i==j:           d[i]=d[i]+1 #Return all non-overlapping...
Scrambled Word Game (Python) Topics: List, tuple In this lab, you will write a scrambled word...
Scrambled Word Game (Python) Topics: List, tuple In this lab, you will write a scrambled word game. The game starts by loading a file containing scrambled word-answer pair separated. Sample of the file content is shown below. Once the pairs are loaded, it randomly pick a scrambled word and have the player guess it. The number of guesses is unlimited. When the user guess the correct answer, it asks the user if he/she wants another scrambled word. bta:bat gstoh:ghost entsrom:monster...
You carry out a test cross to a DdNn plant and obtain the following: 74DdNn, 24...
You carry out a test cross to a DdNn plant and obtain the following: 74DdNn, 24 Ddnn, 16 ddNn, 86ddnn. What is the map distance between genes D and N?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT