what are stream manipulators in C++? write a detail note.
In: Computer Science
Hello guys.
Below is a test im struggling with I have to do it in Java and use
OOP concepts.
Create.
A House class with instance variables erfNumber, location,
noOfRooms,
etc.
Mandatory properties: status(is the asset owned or sold), number
of
years owned, selling price, and buying price.
At least two overloaded constructors that can be used to
instatiate
House objects.
Getter and setter methods for all properties you have
created.
A method checkProfitOrLoss() that returns the profit or loss that
can be
made if the property is sold (sellingPrice-buyingPrice).
A custom toString() method to print out all the properties of a
House
object.
A static counter to keep track of the number of each object
created.
At least 5 more property or vehicle classes such as Farm, Flat,
Bakkie,
RentalCar, etc.
A driver class named AssetManager.
An array of five House objects. The same applies to other classes
created
in Section B.
Methods to add (remember to keep the sizes of the arrays in mind),
sell
assets (sets the status of an asset at a given index of an array to
sold), and
print the contents of each of the objects for each array. Each
method to
have proper Javadoc comments.
Code to enter from input five of each of the assets into respective
arrays
using the add methods just created.
Printing out the contents of all the arrays using the print methods
you have
created to provide an initial asset report.
Change the current value of at least 10 objects from the arrays
using the
getter and setter methods.
Print out the contents of the assets that can be sold at a profit
using the
checkProfitOrLoss method and the methods you have provided an
asset
sales report.
In: Computer Science
what are stream manipulators in C++? Write at least 3 short example programs of stream manipulators.
In: Computer Science
In Java, design and implement a class called Cat. Each Cat class will contain three private variables - an integer representing its speed, a double representing its meowing loudness, and a String representing its name. Using the Random class, the constructor should set the speed to a random integer from 0 to 9, the meowing loudness to a random double, and the name to anything you want; the constructor should take no parameters. Write “get” and “set” methods for each variable, and one that prints all the variables. Finally, write a main method to test the methods in the class. The three variables must be private.
Then design and implement a class called CatOwner. Each CatOwner will have three private variables: a String representing the owner name, an integer representing how much cat food is left, and a cat; each cat should be an instance of the Cat class. The constructor can name the CatOwner anything you want, and the supply of food should be a random number greater than or equal to 10 and less than 50. Each cat’s name should be set to “Tinkles.” The constructor for CatOwner should take no parameters. Write “get” and “set” methods for the owner’s name, the food supply, and all the properties of the cat; also write a feedCat method that decreases the food supply by 1 and prints that the cat was fed. Next, write a method to print all class variables. Finally, write a main method to test your methods.
Design a driver class which instantiates two CatOwner objects. Next, perform the following five steps:
1. Change the name of the first cat owner to “John Doe” and his
dog’s name to “Whiskers.” Change the name of the second cat owner
to “George Washington.”
2. Increase the meowing loudness of the first cat owner’s cat by
.1, and set the speed of the second cat owner’s cat to 5.
3. Double the food supply of the first cat owner, and set the food
supply of the second to 25.
4. Have the first cat owner feed his cat three times, and have the
second cat owner feed his cat twice.
5. Print out all the information for both cat owners.
In: Computer Science
This project will be an exercise in using all that we have covered in these past two weeks: Arrays (one and multidimensional arrays), branching, and input and output files.
Components:
A class called YourLastNameGradebook (Yes, YourLastName IS your last name!!!)
And an external class called SomeNeatExternalSoundingName. This external class will have at least 2 methods: readData and writeData
This project will include
The class with the main method and the other useful methods that will 1) display the arrays, 2) find the averages and store them, 3) find the grades and store them, 4) and display a chart of the final array results to the terminal window.
The external class will 1) read from the input file and 2) write to an output file.
YourLastNameGradebook class's main method will be made up of declarations and method calls. There should be no other code in the main method. (Except for one single print statement stating that the program is finished!)
Declarations:
Actions needed: Note - Do use the size
of the array for your for loops, notthe value
5.
1) Read in (Invoke the readData method in the external class ):
The input file looks like this: project2IN.txt
Leia Organa 98.0 95.5 100.0
Fred Flintstone 65.0 74.5 76.25
Sheldon Cooper 100.0 100.0 99.0
Stan Marsh 89.0 84.0 80.5
Lisa Simpson 93.0 94.5 92.0
When you open the input file, echo this to the terminal window.
The array of names will be read in from the input file. (The
names will be read in as first last but need to be rearranged to
last, first when being read in)
This array of scores will be read in from the input file.
The last element in the scores array will have a zero in it. This will be reserved for the averages (later).
When you close the input file, echo this to the terminal window.
After reading in the data: Row zero from the
names array corresponds to row zero from the
scores array:
names array contains 5 names:
element: Contents:
0 |
Organa, Leia |
1 |
Flintstone, Fred |
2 |
Cooper, Sheldon |
3 |
Marsh, Stan |
4 |
Simpson, Lisa |
Scores array contains 5 rows of 4 elements each
row |
column 0 |
column 1 |
column 2 |
column 3 |
||
0 |
98.0 |
95.5 |
100.0 |
|||
1 |
65.0 |
74.5 |
76.25 |
|||
2 |
100.0 |
100.0 |
99.0 |
|||
3 |
89.0 |
84.0 |
80.5 |
|||
4 |
93.0 |
94.5 |
92.0 |
|||
2) In YourLastNameGradebook class, invoke the method to display the data using a displayData method:
Display the data (using a displayData method) in the terminal window as it is stored in both of the arrays.
Data read in:
last, first: score1, score2, score3
last, first: score1, score2, score3
last, first: score1, score2, score3
last, first: score1, score2, score3
last, first: score1, score2, score3
(Formatting at this point is not important. Include at least one space! This is just echoing what was entered!)
3) Invoke a method that will compute the average in the scores array
4) Invoke a method that will compute the grade for each student
For each student, determine the average score from the three grades and the grade of A, B, C, D, or F
5) Invoke another displayData method that will print out the names, scores, and grades for each student in the terminal window.
6) Invoke the method in the External class that will write the clean chart to the output file project2OUT.txt
7) When done, the last statement of the main is to be an output statement telling the user that the program is finished.
Output is to be neat and clean. Use blank
spaces for readability in both the output file and in the terminal
window.
Upload (to one of your pairs’ Canvas account) ALL the files that
are needed for grading including BOTH .java files and both .txt
files:
Extra Credit:
1) Use printf to create a neat chart with a chart title (centered
above the output) and headers for the data similar to the
following. (2 points)
==========================================================================
Student Grades
Name Score1
Score2
Score3
Average
Grade
==========================================================================
Organa, Leia
98.00
95.50 100.00
.00
x
Flintstone, Fred 65.00
74.50
76.25 .00
x
and so on...
2) Insert a first new line into your input file. Alter this first line to include an integer value to represent the number of rows to be read in as a reference that will declare the sizes of the arrays to be of that size.
(2 points)
Be SURE that both names appear in the beginning
comments! Otherwise only one of you will get
credit.
This is what will be displayed to the terminal
window: This could be cleaned up to be more
readable.
Reading from input file: project2IN.txt
Closing input file: project2IN.txt
Displaying data as stored:
Organa, Leia 98.0 95.5 100.0 0.0
Flintstone, Fred 65.0 74.5 76.25 0.0
Cooper, Sheldon 100.0 100.0 99.0 0.0
Marsh, Stan 89.0 84.0 80.5 0.0
Simpson, Lisa 93.0 94.5 92.0 0.0
Computing Averages...
Average for Organa, Leia is 97.83333333333333
Average for Flintstone, Fred is 71.91666666666667
Average for Cooper, Sheldon is 99.66666666666667
Average for Marsh, Stan is 84.5
Average for Simpson, Lisa is 93.16666666666667
=================================================================
Name Score1 Score2 Score3 Average Grade
=================================================================
Organa, Leia 98.00 95.50 100.00 97.83 A
Flintstone, Fred 65.00 74.50 76.25 71.92 C
Cooper, Sheldon 100.00 100.00 99.00 99.67 A
Marsh, Stan 89.00 84.00 80.50 84.50 B
Simpson, Lisa 93.00 94.50 92.00 93.17 A
Opening the output file: project2OUT.txt
Writing data to the output file.
Closing the output file project2OUT.txt
This program is now terminating. Have a nice day.
Output file: project2OUT.txt
=================================================================
Name Score1 Score2 Score3 Average Grade
=================================================================
Organa, Leia 98.00 95.50 100.00 97.83 A
Flintstone, Fred 65.00 74.50 76.25 71.92 C
Cooper, Sheldon 100.00 100.00 99.00 99.67 A
Marsh, Stan 89.00 84.00 80.50 84.50 B
Simpson, Lisa 93.00 94.50 92.00 93.17 A
In: Computer Science
Compare and contrast the numerous advantages and disadvantages of using a DDBMS.
Describe the optimal situations of when to use a DDBMS and why.
Include the CAP Theorem and BASE in your paper and analyze their importance.
Be sure to integrate an analysis of the mobile wireless revolution, smartphones, tablets, etc. with a focus on social media related to the use of a DDBMS.
PLEASE DO NOT HAND WRITE THE ANSWER!! PLEASE ANSER THE QUESTION THOROUGHLY!! IF YOU CANNOT PROVIDE 1,000 WORDS DO NOT ANSWER THE QUESTION!!
In: Computer Science
For an implementation of kNN classification from scratch in python I am not sure if I correctly calculate the euclidian distance. Help with python code.
import pandas as pd
import numpy as np
import math
import operator
from collections import Counter
class KNN:
def calculate_distance(x1, x2, length):
e_distance = 0
for x in range(length):
e_distance += pow((x1[x] - x2[x]),2)
return math.sqrt(e_distance)
def __init__(self, k=5, p=2):
self.k = k
In: Computer Science
Assignment 2 – Data Types
Research and find the best corresponding Data Types for the following Microsoft Access Data Types from the Micosoft SQL server as well as MySQL DBMS packages.
MS Access MS SQL Server MySQL
Shorttext
Longgtext
Number (Byte)
Number (Integer)
Number (Long Integer)
Number (Decimal)
Number (Double)
Date/Time
Currency
Yes/No
In: Computer Science
You are required to write a program to provide the statistics of a file (Number of letters, number of words, number of vowels, number of special characters and number of digits.
You should implement this problem as a class and call it FileContentStats which provides statistics about the number of letters, number of words, number of vowels, number of special characters, number of lines and number of digits. All of these should be private data members.
(Should be in C++ language)
In: Computer Science
Write a function cube_all_lc(values) that takes as input a list of numbers called values, and that uses a list comprehension to create and return a list containing the cubes of the numbers in values (i.e., the numbers raised to the third power). This version of the function may not use recursion.
In: Computer Science
Write a complete Java program to create three types of counters as follows:
Please follow these notes:
In: Computer Science
Write a 'C' program to calculate the surface area of the cone and by using that, also calculate the volume of the cone and print the values as surface area of the cone and volume of the cone.
where as:
surface area of the cone = πr2 (r is the radius of the surface)
volume of the cone = (1/3)πr2h (h is the height of the cone)
In: Computer Science
void doSomething(int num)
Which of the following would be valid ways to invoke this
method?
答案选项组
System.out.println(doSomething(5));
doSomething("word".length());
doSomething(4);
doSomething(int);
doSomething(4.0);
doSomething(Math.random());
doSomething(7 + 5);
int answer = doSomething(5);
double result = doSometing(23);
doSomething((int)Math.PI);
In: Computer Science
In: Computer Science
I want to know how the application domain is formulated as a CSP(Constraint Satisfaction Problem)?
Thanks~
In: Computer Science