I am trying to write a simple game in Java named GuessNumber.java to run on the command line. This program asks user to pick a number and the computer guesses the number repetitively until the guess is correct and will allow the user to set the lower and upper bound as command line parameters from where the picks the number. If no command line parameters are specified then the program uses a default of 1 to 99.
In: Computer Science
2. Dice rolling (15 pts) Problem Description: Write a program that rolls a pair of six-sided dice, then displays their values sum.
• You can use the random method of the Math class to generate a random number for a die like this: (int) (Math.random() * 6) + 1;
• The application should display special messages for two ones (snake eyes) and two sixes (box cars).
• The application should use static methods (at least two) to organize its code.
• The application should continue only if the user enters “y” or “Y” at the “Roll again?” prompt.
Here is a sample run:
Dice Roller
Roll the dice? (y/n): y
Die 1: 3
Die 2: 1
Total: 4
Roll again? (y/n): y
Die 1: 1
Die 2: 1
Total: 2 Snake eyes!
Roll again? (y/n): y
Die 1: 6
Die 2: 6
Total: 12 Boxcars!
Roll again? (y/n): n
Good bye!
This is for java please check for debugging ! also please leave comments so I could follow steps and better understand
In: Computer Science
(Palindrome integer) Write the methods with the following headers | |
// Return the reversal of an integer, i.e., reverse(456) returns 654 | |
public static int reverse(int number) | |
// Return true if number is a palindrome | |
public static boolean isPalindrome(int number) |
Use the reverse method to implement isPalindrome. A number is a palindrome if its reversal is the same as itself. Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.
Here is a sample run: (red indicates a user input)
Enter a positive integer: 12321
12321 is a palindrome.
Continue? (y/n) y
Enter a positive integer: 12345
12345 is not a palindrome.
Continue? (y/n) n
Good bye!
This is for java if you could make it so it is debugged so theres no inputs that could make it crash! :(
Please leave comments
In: Computer Science
using python
#You've been sent a list of names. Unfortunately, the
names
#come in two different formats:
#
#First Middle Last
#Last, First Middle
#
#You want the entire list to be the same. For this problem,
#we'll say you want the entire list to be Last, First Middle.
#
#Write a function called name_refixer. name_refixer should have
two
#parameters: an output filename (the first parameter) and the
#input filename (the second parameter). You may assume that
every
#line will match one of the two formats above: either First
Middle
#Last or Last, First Middle.
#
#name_refixer should write to the output file the names all
#structured as Last, First Middle. If the name was already
structured
#as Last, First Middle, it should remain unchanged. If it was
#structured as First Middle Last, then Last should be moved
#to the front and a comma should be added after it.
#
#The names should appear in the same order as the original
file.
#
#For example, if the input file contained the following
lines:
#David Andrew Joyner
#Hart, Melissa Joan
#Cyrus, Billy Ray
#
#...then the output file should contain these lines:
#Joyner, David Andrew
#Hart, Melissa Joan
#Cyrus, Billy Ray
#Add your code here!
#The code below will test your function. You can find the
two
#files it references in the drop-down in the top left. If
your
#code works, output_file.txt should have the text:
#Joyner, David Andrew
#Hart, Melissa Joan
#Cyrus, Billy Ray
name_refixer("output_file.txt", "input_file.txt")
print("Done running! Check output_file.txt for the result.")
#If you accidentally erase input_file.txt, here's its
original
#text to copy back in (remove the pound signs):
#David Andrew Joyner
#Hart, Melissa Joan
#Cyrus, Billy Ray
In: Computer Science
Problem: Your have been asked by a cell phone service provider to write a program that will calculate the amount of a customer’s monthly bill. Write a C++ program that will calculate the amount of the bill given the number of lines and the amount of minutes used during the month. Unlimited texting is also offered. '
The cellular service provider offers the following options and pricing: One line for $6/month base cost. Two lines for $12/month base cost.
The voice rates are as follows:
• No minutes: $0
• 1-400 minutes: $9 total
• 401-800 minutes: $16 total
• over 800 minutes: $16 + 1.9 cents/minute over 800 Unlimited texting is $5 extra.
Input: The program should ask the user if they have (A) one line or (B) two lines. Then the program should ask the user to input the number of minutes used in the month (no fractional amounts) Then the program should ask if the user has unlimited text messages (Y or N).
For the first two input values, use an if statement to perform input validation. The user should select only A, or B for the number of lines, and the minutes should be between 0 and 44640 (inclusive).
If either input is invalid, the program should ask the user to reenter the value (but only once, no looping).
Do not validate the response to the last question. 1 Processing: Compute the amount of the monthly bill according to the descriptions above.
If the user answered ‘y’ or ‘Y’ to the last question, your program should add $5 to the bill.
Output: Display the amount of the monthly bill with a dollar sign and formatted to 2 decimal places.
Here are 5 different sample executions of the program: How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 100 Unlimited text messages? (Y/N): N The amount due for the month is $15.00
How many lines: A. One line B. Two lines B Enter the total number of minutes used during the month: 750 Unlimited text messages? (Y/N): Y The amount due for the month is $33.00
How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 850 Unlimited text messages? (Y/N): Y The amount due for the month is $27.95
How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 803 Unlimited text messages? (Y/N): y The amount due for the month is $27.06 2 How many lines: A. One line B. Two lines C Please enter A, or B: A Enter the total number of minutes used during the month: 1234567 Please enter a number between 0 and 44640 for the minutes: 500 Unlimited text messages? (Y/N): n The amount due for the month is $22.00
In: Computer Science
WEEK 6 ASSIGNMENT
In: Computer Science
Your data science experiment now requires four additional data tasks. The first task is to use the list append method to add to the list variable named btcdec1 the BTC price of 14560. The second task is to create a new list with a variable named btcdec2 and append the btc prices of 15630, 12475, and 14972. The third task required you to use the list extend method to add the contents of the list in variable name btcdec2 into the variable name btcdec1. The fourth and final task requires you to use the list sort method in the list named btcdec1 to sort the items in the newly extended list, then use the print statement to output the content of list btcdec1 into the Python console.
In: Computer Science
NEED ASAP PLEASE IF THIS CANNOT BE ANSWERED WITHIN 1 HOUR TO 1.5 HOURS MAX PLEASE DO NOT DO
I DON'T NEED PROBLEMS 1-4 PLEASE ANSWER 5-7 ONLY. ONLY LISTED 1-4 AS A REFERENCE.
This should be in
Type of application :Console application
Language used :C#
Program.cs :
Problem 1:
(15 pts)
Write a C# console program that continually asks the user "Do you want
to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters
either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and
then get keyboard input of the name. After entering the name, display the name to the screen.
Problem 2:
(20 pts) Create a Patient class which has private fields for patientid, lastname,
firstname, age, and email. Create public properties for each of these private fields with get and
set methods. The entire lastname must be stored in uppercase. Create a main class which
instantiates a patient object and sets values for each data item within the class. Display the
data in the object to the console window.
Problem 3:
(15 pts) Modify the Patient class with two overloaded constructors: A new default
constructor which initializes the data items for a patient object using code within the
constructor (use any data). A second constructor with parameters to pass all the data items
into the object at the time of instantiation. Create a test main class which instantiates two
objects. Instantiate the first object using the default constructor and the second object using
the constructor with the parameters.
Problem 4:
(10 pts) Add a static display method in the main class in the patient application
that has a parameter to pass a patient object and display its content.
Problem 5:
(10 pts) Modify the patient class with two overloaded methods to display a bill for a
standard visit based on age. In the first method do not use any parameters to pass in data. If
the patient is over 65, then a standard visit is $75. If the patient is under 65, then the standard
doctors office visit is $125. Build a second method where you pass in a discount rate. If the
patient is over 65, then apply the discount rate to a standard rate of $125. Create a main
method that calls both of these methods and displays the results.
Problem 6:
(20 pts) Create two subclasses called outpatient and inpatient which inherit from
the patient base class. The outpatient class has an additional data field called doctorOfficeID
and the inpatient class has an additional data item called hospitalID. Write a main method that
creates inpatient and outpatient objects. Sets data for these objects and display the data.
Problem 7:
( 10 pts) Modify the base class of Problem 6 to be an abstract class with an abstract
display method called displayPatient that does not implement any code. Create specific
implementations for this method in both the outpatient and inpatient subclasses.
In: Computer Science
You are developing an application that prints out invoice information of customers and cars from dealers. The invoice contains: dealer name, customer name, customer’s phone number, car maker, building year, and total price. Please follow below instructions to write a program.
Part 1 create data types
1. Create an enumerated data type that holds 7 car colors, which are: red, black, white, blue, yellow, gray, and silver;
2. Create a structure for car that holds 4 members: car maker, building year, car color, and total price;
3. Create another structure for customer that holds 2 members: customer name, and customer phone number;
4. Create a third structure for invoice that holds 3 members: dealer name, customer information and car information. The car information is a pointer.
Part 2 define functions
1. Define a function that returns price rate base on the car color. If the car’s color is red, black or white, then the rate is 1. If the color is blue or yellow, then the rate is 1.5. If the color is gray or silver, then the rate is 2;
2. Define a function that copy each member in an invoice variable (e.g., var1) and assign these members to another invoice variable (e.g., var2). Then return this copied invoice variable (var2);
3. Define a function that display invoice information, which includes:
• Dealer name
• Customer name
• Customer phone number
• Car maker
• Car building year
• Car total price
Part 3 manipulate data
A car inventory of cars contains information of three cars: 2018 white Honda, 2019 blue BMW, 2018 silver Tesla. The initial price of each car starts at the price of $30,000. The color base price is $300, and it is varied by multiplying the price rate.
1. Define three pointers that hold char array values for car maker: Honda, BMW, Tesla;
2. Define a C++ string array that holds values of model year;
3. Define a pointer of the car’s type (car pointer) and dynamic allocate an array of size 3;
4. Define a pointer (price pointer) that dynamic allocate an array of size 3. The values pointed by the price pointer and its offsets are total price for each car;
5. Base on color information and price rate, calculate total prices and store them into price pointer and its offsets: total price = initial price + (color base price * price rate);
6. According to above information, store makers, model years, car color, and total price to the car array that pointed by car pointer.
A customer named Tom Smith comes to Carfax to buy the 2019 blue BMW. His phone number I (408)123-4567.
1. Create a variable of invoice type (invoice variable) and store dealer, customer, and car information;
2. Call the display function to print out invoice information.
Later, Tom Smith goes to KBB and buy the 2018 silver Tesla.
1. Create another variable of invoice type (copied invoice variable) and copy contents from invoice variable;
2. Modify contents in copied invoice variable to match the second transaction information;
3. Call the display function to print out this invoice information.
In: Computer Science
C++ program which partitions n positive integers into two disjoint sets with the same sum. Consider all possible subsets of the input numbers.
All in one C++ file.
This is the sample Input 1
6 3 5 20 7 1 14
Output 1
Equal Set: 1 3 7 14
This is the sample Input 2
5 10 8 6 4 2
Output 2
Equal Set: 0
In: Computer Science
Case Study 1: Recent attacks
Case Study 2: Crypto-malware Attacks
Use the Internet to research some of the recent different crypto-malware ransomware attacks.
In: Computer Science
Sun Mon
Tue Wed
Thu
Fri Sat
1 2
3
4
5
6
7
8 9
10 11
12
13
14
15
16
17 18
19
20
21
22
23
24 25
26
27
28
29
30
In: Computer Science
Write an evenTest(n) function that returns True if it is given
an even integer and False if it is given an odd number. The rest of
your code (outside of the function) should get an integer number
from the user, call evenTest(n) to test if the number is even, and
then tell the user if the number was even or odd. Name the program
even_or_odd.py.
Part 2. Salary.py (5 pts) You are offered two options to receive
salary: • Option 1: Constant Salary: Receive $100 each day for 10
days • Option 2: Doubling Salary: $1 the first day, $2 the second
day, $4 the third day, $8 the fourth day, doubling the amount each
day, for 10 days. Define a function constant_salary() that computes
and returns the total income for Option 1. Define a function
doubling_salary() that computes and returns the total income for
Option 2. The rest of your code (outside of the functions) should
call both functions, compare the totals they return, and determine
which salary option pays more. This program does not ask the user
for any input. Name the program salary.py.
In: Computer Science
Design and develop a class named Person in Python that contains two data attributes that stores the first name and last name of a person and appropriate accessor and mutator methods. Implement a method named __repr__ that outputs the details of a person.
Then Design and develop a class named Student that is derived from
Person, the __init__ for which should receive first name and last
name from the class Person and also assigns values to student id,
course, and teacher name. This class needs to redefine the __repr__
method to person details as well as details of a student. Include
appropriate __init__.
Design and develop a class named Teacher that is derived from Person. This class should contain data attributes for the course name and salary. Include appropriate __init__. Finally, redefine the __repr__ method to include all teacher information in the printout.
Implement an application/driver that creates at least two student
objects and two teacher objects with different values and calls
__repr__ for each.
In: Computer Science
JAVA LANGUAGE
Create a new project named BankAccount in Eclipse. Then,
implement the following requirements. You need to create two
classes, one for BankAccount (BankAccount.java) and the other for
the tester (BankAccountTest.java).
Make sure your program compile without errors before submitting.
Submit .java files to eCampus by the end of next Thursday,
10/15/2020.
Part 1: Create the BankAccount class (template is attached after the project description) in the project. You must add the following to the BankAccount class:
An instance variable for bank account number: accountNum
The long getAccountNum() method to get the account number
The void setAccountNum(long acctnum) method to set the account
number
An instance variable for bank account owner’s name: name
The String getAccountName() method to get the account owner’s
name
The void setAccountName(String acctname) method to set the account
owner’s name
Another instance variable for account overdrawn status:
overdrawn
The boolean isOverdrawn() method to get the account overdrawn
status
The void setOverdrawn(boolean status) method to set the account
overdrawn status
A constructor with four parameters: name, account number, the
initial balance, and the overdrawn status to set the initial values
for the instance variables when an object is created
Modify the withdraw() and deposit() methods
An account will be overdrawn if a withdrawal results in a negative
balance.
An account that was overdrawn will not be overdrawn anymore if a
deposit results in a positive balance or 0.
The deposit and withdraw methods must verify the amount to deposit
(or to withdraw). If the amount is negative, the methods must
printout "Negative amount!" and the balance of the account will not
be changed.
Add a method called transfer(double amount, BankAccount
otherAccount)
The transfer method is to transfer some money from the account to
another account specified by otherAccount.
Add a method addInterest ( ) to add interest to the account and
change the balance
use a constant to represent the interest rate 3.5%
Add the toString() method to represent an account in the following
format:
“The Account Number xxx is owned by xxx with a Balance xxx. It is
(not) overdrawn.”
Here xxx needs to replace by the values of the account. If it is
overdrawn, show
overdrawn. Otherwise, show not overdrawn.
Part 2: Create a BankAccountTest class with only the main method in the BankAccount project to test the BankAccount class. You must add the following to the BankAccountTest class:
Create a BankAccount object named harrysChecking with the
initial values: name as "Harry", accoutNum as 12345, balance as
0.00, and overdrawn as false
Print out the object harrysChecking by calling toString()
method
Call the deposit method to deposit $200 to harrysChecking and then
print out the current balance and overdrawn status of
harrysChecking
Call the withdraw method to withdraw $500 from harrysChecking and
then print out the current balance and overdrawn status of
harrysChecking
Again call the deposit method to deposit $400 to harrysChecking and
then print out the current balance and overdrawn status of
harrysChecking
Create a BankAccount object named harrysSaving with the initial
values: name as "Harry", accoutNum as 86754, balance as 500.00, and
overdrawn as false
Print out the object harrysSaving by calling toString()
method
Call the transfer method to transfer $50 from harrysChecking to
harrysSaving
Print out the current balances of harrysChecking and harrysSaving,
respectively
Call the addInterest method to add interest to harrysSaving and
Print out information for harrysSaving by calling toString()
method
/**
A bank account has a balance that can be changed by deposits,
withdrawals, transfers, and interests.
*/
public class BankAccount {
private double balance;
/**
Constructs a bank account with a zero balance
*/
public BankAccount() {
balance=0;
}
/**
Constructs a bank account with a given balance
@param initialBalance the initial balance
*/
public BankAccount(double initialBalance) {
balance=initialBalance;
}
/**
Deposits money into the bank account.
@param amount the amount to deposit
*/
public void deposit (double amount) {
balance=balance+amount;
}
/**
Withdraws money from the bank account.
@param amount the amount to withdraw.
*/
public void withdraw (double amount) {
balance=balance-amount;
}
/**
Gets the current balance of the bank account.
@return the current balance
*/
public double getBalance() {
return balance;
}
}
public class BankAccountTest {
public static void main(String[] args) {
}
}
In: Computer Science