Part 1 (Objective C++ and please have output screenshot)
The purpose of this part of the assignment is to give you practice in creating a class. You will develop a program that creates a class for a book. The main program will simply test this class.
The class will have the following data members:
The class will have the following member functions (details about each one are below:)
You must create your program using the following three files:
book.h – used for declaring your class. In this header file, the declarations of the class and its members (both data and functions) will be done without the definitions. The definitions should be done in the book.cpp file.
book.cpp – contains the definitions of the member functions:
Mp8bookDriver.cpp – should contain the main program to test the class.
It should declare two book objects (book1 and book2) using the default constructor. Call the print function for book1 (to show that the default constructor is correct). Open the input file and call the GetData function for book2 and then print its information. Finally, test the GetISBN function for book2 and output the result returned from the function.
Format of Data file
The name of the data file is mp7book.txt
It has data for one book arranged as follows:
mp7book.txt
Jane Smith
History Of This World
12349876
Get this part of the program working and save all the files before starting on Part 2. The output should be similar to the following:
Testing the book class by (your name)
The information for book 1 is:
No name Unknown title 0
The information for book 2 is:
Jane Smith History Of The World 12349876
book2 has ISBN 12349876
Press any key to continue
Part 2
Now you will use the book class to create an array of books for a small library. Note that the book.h and book.cpp files should not have to be changed at all - you just have to change the main program in the Mp8bookDriver.cpp file.
There is a new data file, mp7bookarray.txt. It contains the information for the books in the library using the same format as described above for each book. There will be exactly 10 books in the file.
Declare an array of books that could hold 10 book objects. Open the new data file and use a loop to call the GetData function to read the information about the books into the objects in the array. Print out the list of books in the library in a nice format. Notice that the books are arranged in order by ISBN in the data file.
Now imagine customers coming into the library who want to know whether a particular book is in the collection. Each customer knows the ISBN of the book. Open the third data file (mp8bookISBN.txt) which contains ISBN's, read each one, and use a binary search to find out whether the book is in the array. If it is found, print out all the information about the book, if not, print an appropriate message. Then repeat the process for each of the ISBN's until you get to the end of the file.
mp8bookarray.txt
H. M. Deitel
C++ How to Program
130895717
Judy Bishop
Java Gently
201593998
Jeff Salvage
The C++ Coach
201702894
Thomas Wu
Object-Oriented Programming with Java
256254621
Cay Horstmann
Computing Concepts with C++
471164372
Gary Bronson
Program Development and Design
534371302
Joyce Farrell
Object-Oriented Programming
619033614
D. S. Malik
C++ Programming
619062134
James Roberge
Introduction to Programming in C++
669347183
Nell Dale
C++ Plus Data Structures
763714704
mp8bokkISBN.txt
201593998
888899999
763714704
111122222
256254621
130895717
488881111
534371302
619033614
In: Computer Science
Use Visual Basic Language
In this assignment,you will create the following data file in Notepad:
25
5
1
7
10
21
34
67
29
30
You will call it assignment4.dat and save it in c:\data\lastname\assignment4\. Where lastname is your last name.
The assignment will be a console application that will prompt the user for a number.
Ex. Console.Write(“Enter a number: ”)
And then read in the number
Ex. Number = Console.ReadLine()
You will then read the data file using a while statement. For each time you read a value from the data file you will compare it to the user input value.
Ex. User inputs the value “10”. The first value from the data file is “25”. 25 is greater than 10, so the output would look like this, “25 is greater than10”. The next value from the data file is “5”, so the output would be “5 is less than 10”.Also check for equal values as well.
You will also total the values from your data file and then average them at the end. Your total will be 229 and the average will be 22.9. The total variable should be a double and rounded to two decimal places. The results should be printed to the screen at the end of the program.
Required elements:
* Comments and documentation
* Data file
* While statement(read the data file)
* Totaling the contents of the data file
* Averaging the total
Variables needed:
* Number (input from the screen): Type Double
* Datanumber (input from the data file): Type Double
* Total (values totaled from data file): Type Double
* AverageData (Average from the total): Type Double
* Const variables of string type: For example:
Const author As String = "Jack"
Const doublelines As String = "=============="
In: Computer Science
MACROECONOMICS PAPER ASSIGNMENT
The Physicians for a National Health Program
and Single Pay National Health Care Insurance
Due April 12
One of our country’s most significant fiscal policy issues is rising health care costs. The Physicians for a National Health Program (PNHP) is a non-profit organization of 20,000 physicians, medical students, and health professionals who support single-payer national health insurance (or Medicare For All) as a means of reforming health care in the United States. It is currently the health care position of Presidential candidates Bernie Sanders and Elizabeth Warren.
For this paper assignment, each student will review the PNHP website (as well as other sources contained in Blackboard) and write a TYPED paper of no more than 300 words with respect to the following:
- What is single payer health care?
- What does PNHP consider the most serious health care spending problem? Why?
- What are PNHP’s biggest problems with Obamacare, which was another way of dealing with health care reform?
- How will single pay health care be paid for?
- Do you agree with PNHP’s positions? If so, why? If not, why not?
Prior to writing your paper, watch the Crash Course Economics video “The Economics of Heath Care” and read the “Health Care Primer” found in the Blackboard folder. As part of your paper, cite at least one outside article or book and reference it at the end (name, author, date, web link). Grading will be based on your knowledge of PNHP’s position, addressing each of the above questions (using the primer and video as a reference), and the thoughtfulness in arguing your position. The paper can be submitted via email attachment or through Blackboard – no hard copies.
In: Economics
Java
Write a method, makeUserName, that is passed two Strings and an int: the first is a first name, the second is a last name, and the last is a random number. The method returns a user name that contains the last character of the first name, the first five characters of the last name (assume there are five or more characters in last name), and the random number. An example: Assume that “John”, “Smith”, 45, are passed when the method is called, it will return “nSmith45” as the user name.
In: Computer Science
Consider the following incomplete declaration of a Name class for 2a-2c.
public class Name something missing
{
private String first;
private String last;
public Name(String firstName, String lastName)
{
first = firstName;
last = lastName;
}
//additional methods
}
2a) In the first two parts, you will modify the Name class so that it implements the Comparable interface. Show here what should go in place of something missing in the first line of the class declaration.
2b) In this part, implement the compareTo method. The standard ordering of names is to be used: alphabetical order by last name, and if the two last names are the same, alphabetical order by first name. Two names are considered the same if and only if both the first and last names are the same.
2c) Implement a toString method in the Name class, which takes no parameters and returns a String containing the full name: first name then last name. For example, if the first name is “John” and the last name is “Doe”, then toString should return “John Doe”.
In: Computer Science
Write a program call FancyMyName which asks you to write a program that tests the usage of different methods for working with Strings.
This program will ask the user to enter their first name and their last name, separated by a space.
Read the user's response using Scanner. Separate the input string up into two strings, one containing the first name and one containing the last name. You can accomplish this by using the indexOf() hint*** find the position of the space, and then using substring() to extract each of the two names. Also output the number of characters in each name (first & last) and output the user's initials. The initials are the first letter of the first name together with the first letter of the last name
A sample run of the program should look something like this:
Please enter your first name and last name, separated by a space?
You entered the name: Steve Henry
Your first name is Steve: has 5 characters
Your last name is Henry: has 5 characters
Your initials are: SH
In: Computer Science
I am working on making a simple grade book that will take user input like name and grade and then return the name and grade of multiple inputs when the person quits the program. Here is the code that I have been working on. This is in Python 3. I can get one line to work but it gives me an error.
Here is what it is supposed to look like:
These are just examples billy 100 greg 60 jane 90 stephanie 70
If I put an name and grade into my code it returns this:
david98
It returns for only one input for each and it finishes with an exit code of 1.
I need to have multiple inputs stored in the dictionary. I am new to dictionaries and I am having a little trouble with it.
Here is the code for my program:
grades = {}
while True:
name = input("Enter a name (or 'quit' to stop): ")
if name == 'quit':
break
grade = input("Enter a grade: ")
def set_grade(name, grade):
global grades
grades[name] = grade
def get_grade(name):
if name in grades:
return grades[name]
def get_name(grade):
if grade in grades:
return grades[grade]
set_grade(name, grade)
print(name + get_grade(name))
print(grade + get_name(grade))
In: Computer Science
In java language how would I write the following?
1. Enter a name and the application must display a message indicating if the name is among the most popular (found on either array)
2. Option to suggest a name. Program must suggest/display a name to the user by randomly selecting one from the appropriate array depending if the user wants a boy’s or girl’s name
3. Option to display all names starting with a specific letter. Display all names starting
with a specific letter (e.g. all names starting with the letter R) depending if the user
wants a boy’s or girl’s name
After a user either enters a name from (1) in the menu or is suggested a name from (2), the program must ask if the name is acceptable for the newborn or not
1. If the name is not acceptable, user must be given the option to exit the program or repeat the procedure. Either ask for a new name to search if user is in (1), or suggest a new name randomly if in (2).
2. If the name is acceptable, program must ask the user to enter the newborn’s last name and expected date of birth.
3. Then, the program must instantiate an object of the class called NewBorn using its constructor with the accepted name for the newborn, last name, and expected date of birth.
4. Finally, program must display the state of the NewBorn object
In: Computer Science
In JAVA (eclipse).... Extract both files and place them in your program’s folder. You will be using them. In your driver class: • Create an array called “boyNames” and store all names from the BoyNames.txt file • Similarly, create an array called “girlsNames” and store all names from the GirlNames.txt file • Create a text menu that allowing users to: 1. Enter a name and the application must display a message indicating if the name is among the most popular (found on either array) If the name is found, tell the user if it is a boy’s or girl’s name 2. Option to suggest a name. Program must suggest/display a name to the user by randomly selecting one from the appropriate array depending if the user wants a boy’s or girl’s name 3. Option to display all names starting with a specific letter. Display all names starting with a specific letter (e.g. all names starting with the letter R) depending if the user wants a boy’s or girl’s name • After a user either enters a name from (1) in the menu or is suggested a name from (2), the program must ask if the name is acceptable for the newborn or not 1. If the name is not acceptable, user must be given the option to exit the program or repeat the procedure. Either ask for a new name to search if user is in (1), or suggest a new name randomly if in (2). 2. If the name is acceptable, program must ask the user to enter the newborn’s last name and expected date of birth. 3. Then, the program must instantiate an object of the class called NewBorn using its constructor with the accepted name for the newborn, last name, and expected date of birth. 4. Finally, program must display the state of the NewBorn object
In: Computer Science
Write a class called Name. A tester program is provided in Codecheck, but there is no starting code for the Name class.
The constructor takes a String parameter representing a person's full name. A name can have multiple words, separated by single spaces. The only non-letter characters in a name will be spaces or -, but not ending with either of them.
The class has the following methods. • public String getName() Gets the name string.
• public int consonants() Gets the number of consonants in the name. A consonant is any character that is not a vowel, the space or -. For this problem assume the vowels are aeiou. Ignore case. "a" and "A" are both vowels. "b" and "B" are both consonants. You can have only one if statement in the method and the if condition cannot have either && or ||. Do not use the switch statement, which is basically the same as an if statement with multiple alternatives. Hint: call method contains().
• public String initials() Gets the initials of the name. Do not use nested loops for the method. Hint for initials(): Each word after the first is preceded by a space. You can use the String method indexOf (" ", fromIndex) to control a while loop and to determine where a new word starts. This version of indexOf() returns the index of the first space starting at the fromIndex. The call of indexOf (" ", fromIndex) returns -1 if the space is not found in the string. Remember that the name does not have 2 consecutive spaces and does not end in a space.
CODE CHECK:
public class NameTester
{
public static void main(String[] args)
{
Name name = new Name("Allison Chung");
System.out.println(name.getName());
System.out.println("Expected: Allison Chung");
System.out.println(name.consonants());
System.out.println("Expected: 8");
name = new Name("a-abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ");
System.out.println(name.getName());
System.out.println("Expected: a-abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ");
System.out.println(name.consonants());
System.out.println("Expected: 42");
name = new Name("Alhambra Cohen");
System.out.println(name.initials());
System.out.println("Expected: AC");
name = new Name("George H W Bush");
System.out.println(name.initials());
System.out.println("Expected: GHWB");
name = new Name("John Jacob Jingleheimer Schmidt");
System.out.println(name.initials());
System.out.println("Expected: JJJS");
name = new Name("Zorro");
System.out.println(name.initials());
System.out.println("Expected: Z");
}
}In: Computer Science