Greetings, I'm working on a class project for fractions and I'm stuck and cannot figure out where to go from here. We have a mandatory driver file we aren't supposed to change. See below for example output and the output I am actually getting. **Sample Output** Enter numerator; then denominator. 5 8 5/8 Enter numerator; then denominator. 4 10 4/10 Sum: 82/80 1.025 Product: 20/80 0.25 Enter numerator; then denominator. 6 0 infinity Driver file import java.util.Scanner; public class NathanialProg7 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); Fraction c, d, x; // Fraction objects System.out.println("Enter …

Member Avatar
Member Avatar
+0 forum 1

Here is my code: ` #include <iostream> #include <iomanip> #include <string> using namespace std; class Register { //Private members private: //Creating an array for all the Prices static double Price[]; //Declaring RegNUM and RecNUM int RegNUM, RecNUM; //Print out Item name in a loop static string items[]; //Creates a Receipt Structure struct Receipt { //Takes in the number of orders and stores items bought int Orders[5]; double Total = 0; }; //Creating a pointer (RecPTR) Receipt *RecPTR; //Public members public: //Register Constructor Register(int,int); //Member functions void getOrder(int); void RecRETURN(); //Operators Register operator+(const Register &right); Register operator=(const Register &right); }; //Setting …

Member Avatar
Member Avatar
+0 forum 4

The tools Hal’s sells are: Hammers: $10.99 Wrenches: $10.99 Levels: $19.99 Tape Measures: $4.99 Screwdrivers: $8.99 In order to make things easier in the long run you have decided to make a c++ program that takes in all the orders for each register and tallies them at the end of the day. Write a c++ program that does the following: Create a Register class that can store all of the receipts for the day and the totals for that register. This class could have the following member functions: Contructor(int) – Creates a number of receipts based on an integer that …

Member Avatar
Member Avatar
+0 forum 3

Kind of stuck here. I'm porting over a section of code from Java to C#, and I'm having an issue with method permissions constructors. Early in my code, i have this class.. public class TCard { int suit; int rank; } and later i've got this method, which throws a bunch of errors. Identifiers highlighted with the double asterixes throw the "is innaccessible due to its protection level" error. I've tried rebuilding my solution, and this hasn't worked. public void loadDeck(TCard[] deck) { int count; for (count = 1; count <= 52; count++) { deck[count] = new TCard(); deck[count].**suit** = …

Member Avatar
Member Avatar
+0 forum 6

I had a programme to write for college in Java. I have missed the class so I won't be getting marked on it but wanted to get it done as I have an exam next we. I am really stuck. I have to create a costInsurance () method taking in the surcharges for 3 conditions yearBuilt, numberOfRooms and hasASpa. I gave a shot at the ageSurcharge but have no idea if this is right or not? public class Hotel{ private String name; private String address; private int yearBuilt; private int numberOfRooms; private boolean hasASpa; public Hotel(String nameIn, String addressIn, int …

Member Avatar
Member Avatar
+0 forum 4

Hello, is this how a constructor is created and initialized. I am getting an error; VB does not like the "New" what I am trying to do is to create a constructor with one argument and initialize its attribute. Public Sub New(ByVal newProdNumber As Long) intProdNumber = newProdNumber End Sub thanks

Member Avatar
Member Avatar
+0 forum 4

Hey there, I am getting used to Java, but here is something that is stumping me: // Fig. 3.10: GradeBook.java // GradeBook class with a constructor to initialize the course name. public class GradeBook { private String courseName; // course name for this GradeBook // constructor initializes courseName with String argument public GradeBook( String name ) // constructor name is class name { courseName = name; // initializes courseName } // end constructor // method to set the course name public void setCourseName( String name ) { courseName = name; // store the course name } // end method setCourseName …

Member Avatar
Member Avatar
+0 forum 6

We cannot use constructors if we want that whenever a pointer is declared, it should be NULL. Am I right Sir? if I declare student *head, *tail, where student is a class, can I make my pointers automatically make NULL using default constructor?

Member Avatar
Member Avatar
+0 forum 3

I'm newbie in C++ programming and I want to declare a constructor from following code in my main however I'm completely confused about it. Here is the code: #include <vector> using namespace std; template <typename HashedObj> class HashTable { public: explicit HashTable( const HashedObj & notFound, int size = 101 ); HashTable( const HashTable & rhs ) : ITEM_NOT_FOUND( rhs.ITEM_NOT_FOUND ), array( rhs.array ), currentSize( rhs.currentSize ) { } const HashedObj & find( const HashedObj & x ) const; void makeEmpty( ); void insert( const HashedObj & x ); void remove( const HashedObj & x ); const HashTable & operator=( …

Member Avatar
Member Avatar
+0 forum 1

I have to write a program that accepts data for a class and then ouputs it in the main. so far i have this. #include<iostream> #include<string> #include<fstream> using namespace std; ifstream infile; class animal { string species; string family; string phylum; string desc; static int count; public: bool readIN(const string fname); void printInfo() const; void setAnimal (string s, string f, string p, string d); static int getCount(); animal(string s, string f, string p, string d); animal(ifstream& file, const string fname); }; int animal::count=4; bool readIN(const string& fname) { infile.open("cat.txt"); return infile; } void animal::setAnimal (string species, string family, string phylum, …

Member Avatar
Member Avatar
+0 forum 1

hi all, In the book "Programming Languages-Pragmatics" second edition by Michael l. Scott and Morgan Kaufmann, there is a sentence while explaining about copy constructor: "In recognition of this intent, a single-argument constructor in C++ is called a copy constructor." This is about the constructor of the form foo::foo(const foo& object); I could understand about that constructor but couldn't understand the statement I have quoted above...I think we cannot state that every single-argument constructor is a copy constructor....If I'm wrong or I seems to be misunderstood the sentence...please help me.... Copy constructor: foo::foo(const foo& object); Normal single argument constructor: foo:foo(int …

Member Avatar
Member Avatar
+0 forum 4

Hi. I am a very beginner at Java. I am taking an online course on Java and I'm stuck on an assignment. Anyone who is good with Java, can you please take a look at my code? This assignment was due yesterday but I couldn't finish it. It is very unfinished, but I'm not sure how to continue because I'm still not familiar with the concept of object oriented programming (getters, setters, constructors, etc). Could anyone please explain more object oriented programming to me? Also what do getters and setters do? And can you give me an example of using …

Member Avatar
Member Avatar
+0 forum 4

I wanted to write a simple program that uses classes but I've been running into errors. Anyone have a clue as to what is wrong with my code because I can't seem to figure it out. #include <iostream> #include <iomanip> #include <cmath> using namespace std; class cone{ private: double radius; double height; public: cone(); void setvolume();// double conevol(); }; //implementation void cone(){ double radius; double height; } void setvolume(double r,double h){ double radius=r; double height=h; } double conevol(double r,double h){ double vol=(1/3.0)*(3.14159265)*r*r*h; return vol; } int main(){ cone A; cout<<"The current volume of the cone is: "<<A.convol<<endl; A.setvolume(3.4,5.63); cout<<"The volume …

Member Avatar
Member Avatar
+0 forum 2

I am trying to get this class put together but I've always had trouble figuring out constructors. I don't know what to set the data fields in Customer(int customerID, int checkoutTime, int arrivalTime){} // DO NOT ADD NEW METHODS OR DATA FIELDS! class Customer { private int customerID; private int checkoutTime; private int arrivalTime; Customer() { // add statements customerID = 0; checkoutTime = 0; arrivalTime = 0; } Customer(int customerID, int checkoutTime, int arrivalTime) { // add statements this.customerID = customerID; customerID = int cust; this.checkoutTime = checkoutTime; checkoutTime = int check; this.arrivalTime = arrivalTime; arrivalTime= int arriv; } …

Member Avatar
Member Avatar
+0 forum 1

Working on this program that uses 2 classes and a client program to test them, I keep getting this error pointing at my constructor, not sure what i am doing wrong but could use some assistance if anyone is able to offer, the error i am getting is: cannot find symbol, constructor GroceryList() line 25 [CODE] GroceryList tempItemOrder = new GroceryList(); [/CODE] here are the files... [CODE] import java.util.*; public class GroceryList extends GroceryItemOrder { private int size = 10; int[] items = new int[size]; //default constructor to handle normal data public GroceryList(String name, int quantity, double unitPrice) { super(name,quantity,unitPrice); …

Member Avatar
Member Avatar
+0 forum 13

I am working on this assignment in my java class, and am running into a few problems. Basically there are 2 classes and a main/client program that tests the classes. there is 1 superclass and a subclass that extends the superclass.. I have 2 constructors in my superclass but when i try to access them from my subclass I receive some errors, I believe I am supposed to create a constructor in my subclass and call the constructor using [CODE] super(arguments); [/CODE] If someone could please explain what exactly I am doing wrong it would be greatly appreciated.. Here are …

Member Avatar
Member Avatar
+0 forum 8

I wonder why they use private constructors.when I was navigating java documentation I found alot of classes with private constructor.Would you tell me what are the benefits of writting them.

Member Avatar
Member Avatar
+0 forum 15

Hi!! my application have 2 frames including tabel 1,tabel 2 when run time i insert values though textfileds to tabel 1 ,after inserting 5 or more then i click next button then display other frame with tabel 2 and tabel 2 must auto filled. my problm is last row(i already insert to 5 or more row to tabel1) only displaying in tabel2 here is my code: tabel1 [CODE] package tabels; import java.util.Vector; import javax.swing.table.DefaultTableModel; public class tabel1 extends javax.swing.JFrame { /** Creates new form tabel1 */ public tabel1() { initComponents(); setLocationRelativeTo(null ); } /////////THIS ARE AUTO GENRETECODES///////// @SuppressWarnings("unchecked") // <editor-fold …

Member Avatar
Member Avatar
+0 forum 1

Suppose the xMethod() is invoked in the following constructor in a class, xMethod() is _________ in the class. public MyClass() { xMethod(); } A. a static method B. an instance method C. a static method or an instance method what is the answer a or b or c

Member Avatar
Member Avatar
+0 forum 15

I've tried searching for articles that relate to this issue, but all I keep finding are articles about people who don't know how to define constructors/can't call the parent constructor/etc and I think this will cut straight to the chase. The problem code is as follows: [CODE] #include <stdio.h> class TestA { public: TestA(){} TestA(const TestA &Temp) { printf("TestA called!\n"); } }; class TestB : public TestA { public: TestB(){} TestB(const TestA &Temp) { printf("TestB called!\n"); } }; int main (const int ArgC, const char *ArgV[]) { TestB Test; TestB Test2(Test); //Calls TestA's constructor TestA(const TestA &Temp), instead of TestB's …

Member Avatar
Member Avatar
+0 forum 3

Ok So Im writing a app which would pick the 'cheapest' plan for a consumer. While writing this I came across something puzzling to me. Why is it starting after the default constructor, the first CellPlan has three arguments passed too it and then the next one two and then one, why can the number be flipped around and be 1,2,3 or: 2,3,1 arguments (after the default constructor)? [CODE] //default constructor public CellPlan() { } public CellPlan(string name, int zip, int minutes) { customerName = name; zipCode = zip; numberOfMinutes = minutes; } // end of CellPlan constructor public CellPlan(string …

Member Avatar
Member Avatar
+0 forum 2

Hello, I have a class Pdisk [CODE] class Pdisk { public : Pdisk(string diskname, int numberofblocks, int blocksize); private : string diskname; int numberofblocks; int blocksize; }; [/CODE] Now I want to make a class filesys which can access an object of class Pdisk. I am not sure how to pass this object. filesys.h: [CODE] class fileSys{ public: Filesys(Pdisk& disk); private: Pdisk disk; }; [/CODE] filesys.cpp file: [CODE] Filesys::Filesys(Pdisk& disk){//...} [/CODE] In my driver program I want to call [CODE] Pdisk disk("disk",64,128); fileSys fsys(disk); [/CODE] I am using Visual C++ and get the error that there is no default constructor. …

Member Avatar
Member Avatar
+0 forum 2

What's wrong with my code? Why can't I output the "hahahaha" string from public constructor1?? help me please. [CODE]using System; namespace hahahahahahahahaha { class Program { public static void Main(string[] args) { constructor1 obj = new constructor1(); } } public class constructor1 { public constructor1(); { Console.WriteLine("hahahaha"); } } }[/CODE]

Member Avatar
Member Avatar
+0 forum 6

So i haven't figured out what the point of constructors are i am just learning C++ and am seriously having trouble with it, i do not get why...well i kind of get default constructors because it initializes the variables but what about a constructor with arguments and the member function

Member Avatar
Member Avatar
+0 forum 10

Here's the scenario: I am coding a program that will display data from a database in a variety of fields. Some of the fields need to be read-only. Should have been simple just to set all those controls to read-only, except some of them are checkboxes, radio buttons and date pickers, which do not support a read-only setting. I could mark them disabled, but that changes the color on the controls, and overriding the colors is more complicated than I want to do. So the solution that I'm trying to implement is to cause an empty label (or other control) …

Member Avatar
Member Avatar
+0 forum 9

I have an assignment where I have been asked to ask the user for input. What I am trying to figure out is if there is anyway to call and use methods of another class whose constructor requires parameters without passing them from the main class that will be calling said methods. i.e. [CODE]public abstract class Employee { private String firstName; private String lastName; private String socialSecurityNumber; // three-argument constructor public Employee( String first, String last, String ssn ) { firstName = first; lastName = last; socialSecurityNumber = ssn; } // end three-argument Employee constructor // set first name public …

Member Avatar
Member Avatar
+0 forum 5

Hello It's me again, some might have seen a similar string, and it is probably because it is the same, but with a different problem. The following shows a program which uses a function that converts Fahrenheit into Celsius. The problem is that a person can enter any value they wish to, including letters, if this happens it will send the program into an infinite loop, so I made the code to read the input as an array, but now it won't go into the function, and the program will simply stop when i compile, anyone know how I can …

Member Avatar
Member Avatar
+0 forum 2

copy constructors ?? what are they ?

Member Avatar
Member Avatar
+0 forum 5

I got to assignment first one was to print the data of two students using different classes and constructors and count the total numbers of records and i've done this. here is the program. [CODE]public class Student { int RollNo; String name; static int stdcount=0; public void print(){ System.out.println ("Roll no: " + RollNo + "" + " Name: " + name); } public Student (){ RollNo= 99999; name = "Name is not set"; stdcount++; } } class Records { public static void main (String args[]) { Student std1 = new Student(); Student std2 = new Student(); std1.RollNo = 2000; …

Member Avatar
Member Avatar
+0 forum 3

hi guys what constructors should i use for this program? [CODE]using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BACKUPEXEFILES { public class cCOPY { private string _directorypath; private string _filename; public string directorypath { get { return _directorypath; } set { _directorypath = value; } } public string filename { get { return _filename; } set { _filename = value; } } } }[/CODE]

Member Avatar
Member Avatar
+0 forum 2

The End.