Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12, Problem 1FTE
The following statement is in a class that uses Swing components:
import java.swing.*;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Take a look at the class declaration below:
package p1;
class Test8{
package p2;
import p1.Test8;
package p3;
import p1.Test8;
import p2.Test9;
int i;
class Test9 extends Test8 {
private int j;
protected int k;
public int I;
}
class TestDemo3{
public static void main(String args[]){
Test8 t8 = new Test8();
Test9 t9 = new Test9();
}
Out of these 4 variables declared in Test8, which are accessible in Test9
directly and by creating Test8 reference? In TestDemo3 main function,
which variables can be used by each of the references t8 and t9?
ontent/2/Array%20of%200bjects-Class%20Activity.pdf
ITDB201: Sample Ex.
O Final Exam Questio.
Java
P Python
C cymath
M Mail
212
100%
Program 25
Write a program in java to create a class Products with the following attributes and
methods. Write a driver class called Mid2 to test your construction.
The specifications for the Products class are:
Attributes
prodld
prodCost
prodQty
totalCost
salesRemark Comment for the sales of the item
id of the Item
cost of the item
Quantity of the item
Total cost of the items
cg SA123
sg 25.00
cg 10
sg: 250.00
Sales above 500 or Sales below 500
Methods:
a) Constructor to set the values of the attributes, prodld, prodCost and prodQty.
b) Getter methods to get the values of prodId, prodCost and prodQty.
c) setTotalCost to update the attribute totalCost after finding the total as product of
prodQty and prodCost
d) setRemark to update the attribute salesRemark with value "Sales above 500" if
(total Cost >500) ,"Sales below 500" otherwise.
e) displayData() to…
Please help me with this , I am stuck ! PLEASE WRITE IT IN C++
Thanks
1) bagUnion: The union of two bags is a new bag containing the combined contents of the original two bags. Design and specify a method union for the ArrayBag that returns as a new bag the union of the bag receiving the call to the method and the bag that is the method's parameter. The method signature (which should appear in the .h file and be implemented in the .cpp file is:
ArrayBag<T> bagUnion(const ArrayBag<T> &otherBag) const;
This method would be called in main() with:
ArrayBag<int> bag1u2 = bag1.bagUnion(bag2);
Note that the union of two bags might contain duplicate items. For example, if object x occurs five times in one bag and twice in another, the union of these bags contains x seven times. The union does not affect the contents of the original bags.
Here is the main file:
#include <cstdlib>#include <iostream>#include "ArrayBag.h"using namespace std;
template…
Chapter 12 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 12.2 - Prob. 12.1CPCh. 12.2 - Prob. 12.2CPCh. 12.2 - Prob. 12.3CPCh. 12.2 - Prob. 12.4CPCh. 12.2 - Prob. 12.5CPCh. 12.2 - Prob. 12.6CPCh. 12.2 - If you are writing an event listener class for a...Ch. 12.2 - Prob. 12.8CPCh. 12.2 - Prob. 12.9CPCh. 12.3 - Prob. 12.10CP
Ch. 12.3 - Prob. 12.11CPCh. 12.3 - Which layout manager arranges components in a row,...Ch. 12.3 - Prob. 12.13CPCh. 12.3 - Prob. 12.14CPCh. 12.3 - Prob. 12.15CPCh. 12.3 - Prob. 12.16CPCh. 12.3 - Prob. 12.17CPCh. 12.4 - Prob. 12.18CPCh. 12.4 - Prob. 12.19CPCh. 12.4 - Prob. 12.20CPCh. 12.4 - Prob. 12.21CPCh. 12.4 - Prob. 12.22CPCh. 12.4 - Prob. 12.23CPCh. 12.4 - Prob. 12.24CPCh. 12.4 - Prob. 12.25CPCh. 12.5 - Prob. 12.26CPCh. 12.5 - Prob. 12.27CPCh. 12 - With Swing, you use this class to create a frame....Ch. 12 - Prob. 2MCCh. 12 - Prob. 3MCCh. 12 - Prob. 4MCCh. 12 - Prob. 5MCCh. 12 - Prob. 6MCCh. 12 - Prob. 7MCCh. 12 - Prob. 8MCCh. 12 - Prob. 9MCCh. 12 - Prob. 10MCCh. 12 - Prob. 11MCCh. 12 - Prob. 12TFCh. 12 - Prob. 13TFCh. 12 - Prob. 14TFCh. 12 - Prob. 15TFCh. 12 - Prob. 16TFCh. 12 - Prob. 17TFCh. 12 - Prob. 18TFCh. 12 - Prob. 19TFCh. 12 - Prob. 20TFCh. 12 - The following statement is in a class that uses...Ch. 12 - Prob. 2FTECh. 12 - Prob. 3FTECh. 12 - Prob. 4FTECh. 12 - Prob. 5FTECh. 12 - Prob. 1AWCh. 12 - Prob. 2AWCh. 12 - The variable myWindow references a JFrame object....Ch. 12 - Prob. 4AWCh. 12 - Prob. 5AWCh. 12 - Prob. 6AWCh. 12 - Prob. 7AWCh. 12 - Prob. 8AWCh. 12 - Prob. 9AWCh. 12 - Prob. 1SACh. 12 - Prob. 2SACh. 12 - Prob. 3SACh. 12 - Prob. 4SACh. 12 - Retail Price Calculator Create a GUI application...Ch. 12 - Prob. 2PCCh. 12 - Prob. 3PCCh. 12 - Travel Expenses Create a GUI application that...Ch. 12 - Prob. 5PCCh. 12 - Joes Automotive Joes Automotive performs the...Ch. 12 - Prob. 8PC
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Java: Abstraction using Interfacearrow_forwardC# Programming What is the wrong of this code? Can you fix the error on this part? See attached photo for referencearrow_forwardSee ERROR in Java file 2: Java file 1: import java.util.Random;import java.util.Scanner; public class Account {// Declare the variablesprivate String customerName;private String accountNumber;private double balance;private int type;private static int numObjects;// constructorpublic Account(String customerName, double balance, int type) { this.customerName = customerName;this.balance = balance;this.type = type;setaccountNumber(); // set account number functionnumObjects += 1;}private void setaccountNumber() // definition of set account number{Random rand = new Random();accountNumber = customerName.substring(0, 3).toUpperCase();accountNumber += type;accountNumber += "#";accountNumber += (rand.nextInt(100) + 100);}// function to makedepositvoid makeDeposit(double amount){if (amount > 0){balance += amount;}}// function for withdrawboolean makeWithdrawal(double amount) {if (amount < balance)balance -= amount;elsereturn false;return true;}public String toString(){return accountNumber +…arrow_forward
- mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…arrow_forwardproblem statement: Write a java classStringCheckto do the below given checks on accepted string or strings. Each function should be coded in separate methods of the class. Give appropriate instance variables to implement the method. The user should be able to enter the string through the main function in Main class. Use a constructor to initialize the String entered by the user. Use the Main class to test all the methods in StringCheckclass. The programs should have the below given checklist: 1)Define classStringCheck with required instance variables 2)The StringCheck class should have six methods to do the below functions: *Check if the user entered string is a simple sentence? (Starts with capital letter, Ends with period, space between words). *Check if the user entered string is a question? (Check if the string starts with ac apital letter ends with a question mark, space between words) *Check if the user entered string have numbers in it? *Check if string is a valid email *Check…arrow_forwardExample in Java Write and use classes with instance variables and their getters and setters. static and/or constant data default and overloaded constructors methods and overloaded methods toString() equals() 7. aggregationarrow_forward
- C++ Programing NOTE: The important method has been ATTRIBUTES given to you. userld:int //generates unique id from 10001 upwards INSTRUCTION 1 username:string firstname:string lastname:string dob:string The program should generate unique userld whenever new object is created. Notice that idGenerator is static variable, so assign the current value of idGenerator to userld, so that each user will have unique user id (Starting from 10001). age: int idGenerator: static int; totalUsers : static int МЕТHODS User() User(string, string, string, int) User(const User&) "User() Then increment idGenerator by 1. INSTRUCTION 2 The totalusers is also a static variable. This should keep track of the total users in the class. With the Above UML for CLASS USER, answer the following questions Complete or Create the default constructor method. a. The default constructor should accept just the firstname, lastname, dob (date of birth) and age from the keyboard. wwww w b. Write a setter method that sets the…arrow_forwardInstructions: In the code editor, you are provided with a treasureChestMagic() function which has the following description: Return type - void Name - treasureChestMagic Parameters - an address of an integer Description - updates the value of a certain integer randomly You do not have to worry about how the treasureChestMagic() function works. All you have to do is ask the user for an integer and then call the treasureChestMagic() function, passing the address of that integer you just asked. Finally, print the updated value of the integer inputted by the user. Please create a main code for my function that works with this. This is my code: #include<stdio.h>#include<math.h> void treasureChestMagic(int*); int main(void) { // TODO: Write your code here return 0;} void treasureChestMagic(int *n) { int temp = *n; int temp2 = temp; *n = *n + 5 - 5 * 5 / 5; temp2 = (int) pow(2, 3); if(temp % 3 == 0) { *n = temp * 10; } else if(temp %…arrow_forward3. Set the username for the newly created object to "user+userld"(user10001).arrow_forward
- Pythonarrow_forwardCourse: Data Structure and Algorithims Language: Java Kindly make the program in 2 hours. Task is well explained. You have to make the proogram properly in Java and attach output screen with program: Restriction: Prototype cannot be change you have to make program by using given prototype. TAsk: classBSTNode { Node left; Node right; int data; publicBSTNode(int _data);// assign data to_data and assign left and right node to null } class BST { BSTNoderoot; public BST();// assign root to null void insert(int data);// this function insert the data in tree which maintain property of BST boolean Search(int key); this function search the data in bst and return true if key is found else return false public void EvenPrint(Node n)// this function only print the data which are even, make this function resursive public void OddPrint(Node n)// this function only print the data which are odd, make this function resursive public void PrimePrint(Node n)// this function only…arrow_forwardJava: Design the class Circle that can store the radius and the center of the circle based on the class Point we talked in the class. You should be able to perform the usual operation on a circle, such as setting radius, printing the radius, calculating and printing the area and circumference, and carrying out the usual operations on the center. Here is the code: public class Point {public static void main(String[] args) { } protected double x, y; // coordinates of the Point //Default constructorpublic Point(){setPoint( 0, 0 );} //Constructor with parameterspublic Point(double xValue, double yValue ){setPoint(xValue, yValue );} // set x and y coordinates of Pointpublic void setPoint(double xValue, double yValue ){x = xValue;y = yValue;} // get x coordinatepublic double getX(){return x;} // get y coordinatepublic double getY(){return y;} // convert point into String representationpublic String toString(){return "[" + String.format("%.2f", x)+ ", " + String.format("%.2f", y) + "]";}…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY