1- public class StringRef { 2- public static void main(String[] args) { 3 int x-9; 4 String s1 = "abc" String s2 = "def"; 6 String s3 = s2; 5. 7 s2 = "ghi"; = (x < 15) ? "small" : "tiny"; 8 String sup System.out.println(s1 + s2.charAt(1) + 53.indexof ('d')); 10 %3D System.out.println(sup.charAt(2)); }} 11
Q: Java Constructor(String) This constructor will take a string of digits(no commas) and turn it into…
A: Actually, the answer has given below:
Q: int main() { int i, salary[10], range[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; double gross[10], total[10];…
A: The regular expression (RE) contains the symbol 0 and 1 only. The expression is:…
Q: Language/Type: Java classes Write a class of objects named Date that remembers information about a…
A: Below I have provided a program for the given question. Also, I have attached a screenshot of the…
Q: public class Password { String password; String SPECIAL_SYMBOLS = "!@#$%^&*"; public boolean…
A: import java.util.*; class Password { String password;String SPECIAL_SYMBOLS = "!@#$%^&*"; public…
Q: * Author: Omar Yousef Date: 02/10/2022 A program that outputs a bank account */ public class…
A: Errors in the above program: There should be sapce between each token in the Java program.…
Q: 1. Add a field to the Hexagon.java class called side. It should be a double. 2. Write a no arguments…
A: Constructor is called when a instance of the class is created. It is used to initialize the object.…
Q: public class Student { private String name; private String major; privatedoublegpa;…
A: To fix the main method so it does not print out the memory location, you need to modify the way the…
Q: itialBalance; } public Account () { balance = 0; } public void deposit (double amount){ balance +=…
A: the code is an given below :
Q: /VotingMachine.java:63: error: class Assignment03 is public, should be declared in a file named…
A: Here this program might run by removing the public access specifier in the class Assignment03.
Q: The base class Pet has protected fields petName, and petAge. The derived class Cat extends the Pet…
A: The main() method of a program that makes instances of the Pet and Cat classes and prints their…
Q: public class Number { private int num; public Number(int n) { num = n; } /*…
A: 1. Import the Scanner class for user input.2. Define a `LabProgram` class.3. Inside the `LabProgram`…
Q: homework instructions- Read the steps carefully and follow them correctly. side note- please don’t…
A: I have provided JAVA CODE along with OUTPUT SCREENSHOT---------------- An exception is a…
Q: /* TestCarSensor.java - program to test the CarSensor class. */ public class TestCarSensor { public…
A: Errors in CarSensor.java: The class had below errors: Data type was missing for data member: error,…
Q: Translate the following C++ code to MIPS assembly language in Mars with
A: Writing MIPS assembly code is a common task for those who are working in computer science or related…
Q: public class Car { public void m1( { Sustem.Qut.printla("car 1"); } public void m2() { super.m1(); }…
A: answer is
Q: vlysteryExami Language/Type: Java parameters return The following console program uses parameters…
A: Here we have a function named hamburger(), which takes 3 string parameters, prints them on the…
Q: public class Stadium extends baseStadium{ public int typeTicket; int floors; int seating;…
A: The code includes three classes: Stadium, ticket, and baseStadium, and one interface TicketService.…
Q: Neight(lb): " + shipWeightPounds); lat foofconte)" ELAT EEE CENTS). w. Special character legend…
A: I have answered below:
Q: Bread Class breadType: String - caloriesPerslice: integer + Bread(String breadType, integer…
A: - refers to private members + refers to public members
Q: when printing Weigh no value shows up code public class HealthProfile { private String _FirstName;…
A: The problem is due to name resolution in the constructor,when we change it this it will work…
Q: dayOfWeek (1) "Sunday" dayOfWeek (4) "Wednesday" Your Answer: 1 public String dayOfWeek (int dayNum)…
A: JAVA Program: import java.util.Scanner;public class Week{ // Function dayOfWeek to get the day…
Q: 1 a. is the amount the same, yes or no, why? public class CheckingAct { private String…
A: As per my company rule, I can solve the first three subheadings only. please post the remaining as a…
Q: // DebugFive3.java // Determines whether item number on order is valid // Over 999 invalid // Less…
A: // DebugFive3.java// Determines whether item number on order is valid// Over 999 invalid// Less than…
Q: Q1. amount the same, y, n, why? public class CheckingAct { private String actNum; private…
A: Dear Student, We valued your time. But as per guidelines, I can give answer only to the first…
Q: class temporary { public: void set(string, double, double); void print(); double manipulate();…
A: Algorithm:Include necessary libraries:Include the required C++ libraries for input and output…
Q: 4. Which line(s) of code will produce an error? * package letter; package shape; import letter.A;…
A: As in the first package letter We have created the class A . The class A have the priavte int x .…
Q: Write a function getNeighbors which will accept an integer array, size of the array and an index as…
A: An integer array, its size, and an index are sent to the C++ function getNeighbors, which returns a…
Q: Fix all the errors and send the code please // Application looks up home price // for different…
A: After removing error, the resulting Java codes are: import java.util.*;public class DebugEight3{…
Q: public class Person { private String personID; private String firstName; private String lastName;…
A: Your code is also correct but I have provided more efficient code below.
Q: using static System.Console; class DebugOnel { static void Main() { Writeline("This program displays…
A: - We have to give the error free code for the code used.
Q: int main() { string str; int count = 0; // user input cout > str; int n =…
A: C program to solve the given problem is below.
Q: Public classTestMain { public static void main(String [ ] args) { Car myCar1,…
A: Solution: Given,
Q: class temporary { public: void set(string, double, double); void print(); double manipulate();…
A: Algorithm:Include necessary libraries:Include the required C++ libraries for input and output…
Q: public class SidePlot { public static String PLOT_CHAR = "*"; public static void main(String[] args)…
A: I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT------
Q: The program should have a main method and another method called passwordChecker. The main method…
A: This is very simple. Here is the complete and correct Java code for the given problem. Note: The…
Q: Complete the Course class by implementing the printRoster() method, which outputs a list of all…
A: Create a Course object representing a course.Initialize variables first, last, and gpa to store…
Q: Given main() and a base Book class, define a derived class called Encyclopedia with member methods…
A: As per the given information, I need to provide the code for Encyclopedia class.Algorithm for…
Q: What is outpout?
A: In step 2, I have provided answer , then I have provided JAVA CODE along with CODE SCREENSHOT…
Step by step
Solved in 4 steps with 2 images
- interface StudentsADT{void admissions();void discharge();void transfers(); }public class Course{String cname;int cno;int credits;public Course(){System.out.println("\nDEFAULT constructor called");}public Course(String c){System.out.println("\noverloaded constructor called");cname=c;}public Course(Course ch){System.out.println("\nCopy constructor called");cname=ch;}void setCourseName(String ch){cname=ch;System.out.println("\n"+cname);}void setSelectionNumber(int cno1){cno=cno1;System.out.println("\n"+cno);}void setNumberOfCredits(int cdit){credits=cdit;System.out.println("\n"+credits);}void setLink(){System.out.println("\nset link");}String getCourseName(){System.out.println("\n"+cname);}int getSelectionNumber(){System.out.println("\n"+cno);}int getNumberOfCredits(){System.out.println("\n"+credits); }void getLink(){System.out.println("\ninside get link");}} public class Students{String sname;int cno;int credits;int maxno;public Students(){System.out.println("\nDEFAULT constructor…def SomeMethod(a,b): a= a+b b=b+a print(a,b,end=" ") return (a+b) def main(): x=10 y=20 print(SomeMethod(x,y)) main() x and y are called: ? a and b are called: ?// This class discounts prices by 10% public class DebugFour4 { public static void main(String args[]) { final double DISCOUNT_RATE = 0.90; int price = 100; double price2 = 100.00; tenPercentOff(price DISCOUNT_RATE); tenPercentOff(price2 DISCOUNT_RATE); } public static void tenPercentOff(int p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println("Ten percent off " + p); System.out.println(" New price is " + newPrice); } public static void tenPercentOff(double p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println"Ten percent off " + p); System.out.println(" New price is " + newprice); } }
- public class Author2 {3 private String name;4 private int numberOfAwards;5 private boolean guildMember;6 private String[] bestsellers;78 public String Author()9 {10 name = "Grace Random";11 numberOfAwards = 0;12 guildMember = false;13 bestsellers = {"Minority Report", "Ubik", "The Man in the HighCastle"};14 }1516 public void setName(String n)17 {18 name = n;19 }20 public String getName()21 {22 return name;23 }2425 public void winsAPulitzer()26 {27 System.out.println(name + " gave a wonderful speech!");28 }29 } 1. This class includes a constructor that begins on line 8; however, it contains an error. Describe the error. 2. Rewrite the constructor header on line 8 with the error identied in part c of this question corrected. 3. Demonstrate how you might overload the constructor for this class. Write only the header. 4. Write a line of Java code to create an instance (object) of this class. Name it someAuthor. 5. Write a line of code to demonstrate how you would use the someAuthor object…public static class Lab2{public static void Main(){int idNum;double payRate, hours, grossPay;string firstName, lastName;// prompt the user to enter employee's first nameConsole.Write("Enter employee's first name => ");firstName = Console.ReadLine();// prompt the user to enter employee's last nameConsole.Write("Enter employee's last name => ");lastName = Console.ReadLine()// prompt the user to enter a six digit employee numberConsole.Write("Enter a six digit employee's ID => ");idNum = Convert.ToInt32(Console.ReadLine());// prompt the user to enter the number of hours employeeworkedConsole.Write("Enter the number of hours employee worked =>");// prompt the user to enter the employee's hourly pay rateconsole.Write("Enter employee's hourly pay rate: ");payRate = Convert.ToDouble(Console.ReadLine());// calculate gross paygrossPay = hours * payRate;// output resultsConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3}",firstName, lastName, idNum,…Integer userValue is read from input. Assume userValue is greater than 1000 and less than 99999. Assign tensDigit with userValue's tens place value. Ex: If the input is 15876, then the output is: The value in the tens place is: 7 2 3 public class ValueFinder { 4 5 6 7 8 9 10 11 12 13 GHE 14 15 16} public static void main(String[] args) { new Scanner(System.in); } Scanner scnr int userValue; int tensDigit; int tempVal; userValue = scnr.nextInt(); Your code goes here */ 11 System.out.println("The value in the tens place is: + tensDigit);
- Computer engineering question Apex Test ClassDesgin a apex Salesforce Program to "test"Check the String is exactly same from the start and endUsing the below Apex Program if string is same as it reverse then display the use the assert to test the accuracy of the program: - public class palindrome {public static Boolean myPalindrome(String inputString){String reverseString ='';reverseString = inputString.reverse();if(inputString.equals(reverseString)){return True;}else{return False;} } } Please design the Apex Test Classclass Course { private String courseNumber; private String courseName; private int creditHrs; public Course (String number, String name, int creditHrs){ this.courseNumber = number; this.courseName = name; this.creditHrs = creditHrs; } public String getNumber() { return courseNumber; } public String getName() { return courseName; } public int getCreditHrs() { return creditHrs; } public void setCourseNumber(String courseNumber) { this.courseNumber = courseNumber; } public void setCourseName(String courseName) { this.courseName = courseName; } public void setCreditHrs(int creditHrs) { this.creditHrs = creditHrs; }}class Student { private String firstName; private String lastName; private String gender; private String phoneNumber; private String email; private String jNumber; protected ArrayList courseList; public String getFullName() {…public class Person { private String personID; private String firstName; private String lastName; private String birthDate; private String address; public Person(){ personID = ""; firstName = ""; lastName = ""; birthDate = ""; address = ""; } public Person(String id, String first, String last, String birth, String add){ setPerson(id,first,last,birth,add); } public void setPerson(String id, String first, String last, String birth, String add){ personID = id; firstName = first; lastName = last; birthDate = birth; address = add; } public String getFirstName(){ return firstName; } public String getLastName(){ return lastName; } public String getBirthdate(){ return birthDate; } public String getAddress(){ return address; } public void print(){ System.out.print("\nPerson ID = " + personID); System.out.print("\nFirst Name = " +firstName); System.out.print("\nLast Name = " +lastName); System.out.print("\nBirth Date = " +birthDate); System.out.print("\nAddress = " +address); } public String…
- this is my retail item code: //Import statements public class RetailItem { private String description; private int units; private double price; public RetailItem() { } public RetailItem(String x, int y, double z) { description = x; units = y; price = z; } public RetailItem(RetailItem i) { } public void setDescription(String x) { description = x; } public void setPrice(double z) { price = z; } void setUnits(int y) { units = y; } public int getUnits() { return units; } public String getDescription() { return description; } public double getPrice() { return price; } // Main class public static void main(String[] args) { String str = "Shirt"; RetailItem r1 = new RetailItem("Jacket", 12,…class Container {private int val1=1;private void printValue(){final int val2=2;class Containee{public void f(){System.out.println(String.format("Values are: %d and %d."),val1);}}}public static void main(String[] args) {(new Container()).printValue();}} a.The above does not compile because the method f() requires an instance of class Container b.The above does not compile because the class definition in done within the body of the function c.The above code complies with no errors, but does not produce any ouput d.The above code does not compile because the methodf() cannot access the variable val1PYTHON!! class Triangle: def __init__(self,sides): self.a = sides[0] self.b = sides[1] self.c = sides[2] if __name__ == '__main__': t = Triangle([3,6,2]) print(f'Side1 = {t.a}') print(f'Side2 = {t.b}') print(f'Side3 = {t.c}') Based on the code. Assume you are in the Triangle class: Create a method called calcArea. It will calculate and return the area of the triangle using this formula: