Questions
PROBLEM: c++ code You are to write a program to tell you how many months it...

PROBLEM: c++ code

You are to write a program to tell you how many months it will take to pay off a loan, as well as the total amount of interest paid over the life of the loan.

You have just purchased a stereo system that costs $1000 on the following credit plan: No down payment, an interest rate of 18% per year (and hence 1.5% per month), and monthly payments of $50. The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt. Hence, the first month you pay 1.5% of $1000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt which leaves you with a debt of $965.00. The next month you pay interest of 1.5% of $965.00, which is $14.48. Hence, you can deduct $35.52 (which is $50 - $14.48) from the amount you owe.

Write a program that will tell you how many months it will take you to pay off the loan, as well as the total amount of interest paid over the life of the loan. Use a loop to calculate the amount of interest and the size of the debt after each month. Put out the monthly amount of interest paid and remaining debt. Use a variable to count the number of loop iterations and hence the number of months until the debt is zero. You may want to use other variables as well.

You are to hand in:

  • a Title page
  • a Hierarchy Chart
  • a fully commented Program Listing
  • 3 sample runs (one run uses the above example, one run with your data, one run with invalid loan, interest rate and amount paid)
  • a User’s Guide (showing Purpose, Sample Input, Sample Output, Assumptions/Limitations)

A sample session may run as follows:

Enter the amount of the loan                           1000.00

Enter the yearly interest rate                           18.0

Enter the monthly amount paid                      50.00

Month                  Principle              Interest                 Principle              Remaining

Paid                      Paid                      Balance

              

1                            1000.00                15.00                    35.00                    965.00

2                            965.00                 14.48                    35.52                    929.48

3                            929.48                 13.94                    36.06                    893.42

.

.

24                             47.12                   0.71                    49.29                    -2.17

Number of months to pay of the loan:           24

Total interest paid on loan:                             197.83

You have a credit of:                                       -2.17

In: Computer Science

In C++ The greatest common divisor (GCD) of two integers in the largest integer that evenly...

In C++

The greatest common divisor (GCD) of two integers in the largest integer that evenly divides each of the numbers. Write a function called GCD that has a void return type, and accepts 3 parameters (first two by value, third by reference). The function should find the greatest common divisor of the first two numbers, and have the result as its OUTGOING value.

Write a main function that asks the users for two integers, and uses your function to find the greatest common divisor and then prints that value out.

In: Computer Science

Hi, I have created the following code and I was wondering if it is possible to...

Hi, I have created the following code and I was wondering if it is possible to make an "if" statement in the first for loop that would output an error if the user enters a float, character or string? I was thinking of something along the lines of: if(a[i] != int) but that didn't work :( Thank you.

#include <iostream>
using namespace std;
// Creating a constant for the number of integers in the array
const int size = 10;
int main()
{
// Assigning literals to the varibles
int a[size];
int sum=0;
float avg;
// For loop that will reiterate until all 10 integers are entered by the user
for(int i=0; i<size; i++)
{
cout<<"Enter integer value: ";
cin>>a[i];
}

cout<<"Your array contains the following numbers: "<<endl;
// For loop will display all the integers entered by the user
for(int i=0; i<size; i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
cout<<"From your list of 10 numbers:"<<endl;
// Determines the minimum integer entered
int min = a[0];
for(int i=1; i<size; i++)
{
if (min>a[i])
min=a[i];
}
// Displays the minimum
cout<<"The minimum is: "<<min<<endl;
// Determines the maximum integer entered by the user
int max = a[0];
for (int i=1; i<size; i++)
{
if (max<a[i])
max=a[i];
}
// Displays the maximum
cout<<"The maximum is: "<<max<<endl;
// Computes the sum of all the integers entered by the user
for (int i=0; i<size; i++)
{
sum+=a[i];
}
}
// Displays and computes the sum off all the integers
cout<<"The sum is: "<<sum<<endl;
// Computes the average of all the integers
avg = sum/10.0;
cout<<"Average is: "<<avg<<endl;
return 0;
}

In: Computer Science

Q1: What is the difference between function prototype and function definition in C++? Explain. Q2: What...


Q1: What is the difference between function prototype and function definition in C++? Explain.

Q2: What does function prototype consist off and what does function definition consists of? (hint: components)

Q3: Do the names of parameters have to agree in the prototype, definition, and call to the function? Why or why not, explain?

In: Computer Science

Write a class named Car that has the following fields: • yearModel: The yearModel field is...

Write a class named Car that has the following fields: • yearModel: The yearModel field is an int that holds the car's year model. • make: The make field is a String object that holds the make of the car. • speed: The speed field is an int that holds the car's current speed. In addition, the class should have the following methods: • Constructor: The constructor should accept the car's year model and make as arguments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. • Accessor: The appropriate accessor methods should be implemented to access the values stored in the object's yearModel, make, and speed fields. • accelerate: The accelerate method should add 5 to the speed field when it is called. • brake: The brake method should subtract 5 from the speed field each time it is called. Demonstrate the class in a program that contains a Car object, and then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and print it on a separate line. Then, call the brake method five times, each time printing the current speed of the car on a separate line.

In: Computer Science

Using Java Calculating the tip when you go to a restaurant is not difficult, but your...

Using Java

Calculating the tip when you go to a restaurant is not difficult, but your restaurant wants to suggest a tip according to the service diners receive. Write a program that calculates a tip according to the diner’s satisfaction as follows:

•Ask for bill amount

•Ask for the diners’ satisfaction level using these ratings: 1 = Totally satisfied, 2 = Satisfied, 3 = Dissatisfied.

•If the diner is totally satisfied, calculate a 20 percent tip.

•If the diner is satisfied, calculate a 15 percent tip.

•If the diner is dissatisfied, calculate a 10 percent tip.

•Report the satisfaction level and tip in dollars and cents

Format tips to 2 decimal points; if the bill is 105$ and satisfaction level is 3, then the tip will be $10.50

In: Computer Science

Students in an institute have their name, id, and total score (out of 100) recorded. You...

Students in an institute have their name, id, and total score (out of 100) recorded. You are required to write a Python class to represent the student. Your code should display “Pass” or “Fail”, where the pass-score is above 60. Write the constructor, and other required methods to complete your code. Test the class by creating two objects of the class, where one student fails and the other passes.

In: Computer Science

Write a Python class to represent a Salik account. The account has three attributes, a name,...

Write a Python class to represent a Salik account. The account has three attributes, a name, id, and the balance. The balance is a private attribute. The class has extra functions to add to the balance and reduce the balance. Both, these functions should return the current balance and if the balance is below AED 50.0 print the message “Note: Balance Below 50”.

Your class must work for the code given below.

 
#Test
myCar = SalikAccount()
myCar.setName("John")
myCar.setID("190300300333")
myCar.setBal(20.0)

yourCar = SalikAccount("Ahmed", "102003993", 78.5)

myCar.addBalance(500)
yourCar.reduceBalance(40)

In: Computer Science

c++ input 10 number and calclute the midrange using (largest - smallest)/2.0. use for loop note...

c++
input 10 number and calclute the midrange using (largest - smallest)/2.0. use for loop
note : dont use arrays

In: Computer Science

prove lcs algorithm class finds the optimal solution

prove lcs algorithm class finds the optimal solution

In: Computer Science

Copy Constructor and Operator Overloading. You are given a Date class that stores the date as...

Copy Constructor and Operator Overloading.

You are given a Date class that stores the date as day, month, year and an image of a flower.

The image of the flower is an object which stores a simple string with the flowers type.

This is an example of class composition/aggregation. There are a few important things to bear in mind.

  1. Need for copy constructor
  2. Ability to do operator overloading
  3. Need to release dynamic memory – using destructor

You are given the specification files Date.h and Image.h. Write the implementation files Date.cpp and Image.cpp. You are given a driver that creates Date objects, copies date objects and compares date objects. Your implementations should make the driver produce the correct output.

main.cpp

#include <iostream>
#include "Date.h"
int main()
{
Date first(1,2,2019,"Rose");
Date second(1,3,2019,"Lily");
Date third(first);
  
cout<<"First Date : "<<first.toString()<<endl;
cout<<"Second Date: "<<second.toString()<<endl;
cout<<"Third Date: "<<third.toString()<<endl;

if (second>first) cout<<"Second Date is more recent"<<endl;
first.setPic("Change");
cout<<"First Date now: "<<first.toString()<<endl;
cout<<"Third Date now: "<<third.toString()<<endl;
Date fourth= second;
cout<<"Fourth Date: "<<fourth.toString()<<endl;
second.setPic("Hibiscus");
cout<<"Second Date now: "<<second.toString()<<endl;
cout<<"Fourth Date now: "<<fourth.toString()<<endl;

}

Image.h
#include <string>
using namespace std;

class Image
{
string picture;
public:
Image(string s);
string getPicture();
void setPicture(string newPic);
};

Date.h

using namespace std;
#include <vector>
#include<memory>
#include<string>
#include "Image.h"
#include<iostream>
class Date{
int day,month,year;
shared_ptr<Image> pic;
//Image *pic;

public:
Date();
Date(int day, int month, int year, string picture);
Date(const Date &copyDate);// copy constructor

bool operator>(const Date &otherDate);// operator overlaoding

int getDay() const;

string getPicture()const; //returns the string representing the picture from the image object

shared_ptr<Image> getPic() const; // returns the image

int getMonth() const;
int getYear() const;

void setPic(string newPic) const;

Date& operator=(const Date &otherDate);// operator overloading


string toString();

};

Goal:
Write the implementation files Date.cpp and Image.cpp.

Expected Output:
First Date : Date: 2/1/2019 Rose
Second Date: Date: 3/1/2019 Lily
Third Date: Date: 2/1/2019 Rose
Second Date is more recent
First Date now: Date: 2/1/2019 Change
Third Date now: Date: 2/1/2019 Rose
Fourth Date: Date: 3/1/2019 Lily
Second Date now: Date: 3/1/2019 Hibiscus
Fourth Date now: Date: 3/1/2019 Lily

In: Computer Science

Q#2 Write a C++ program that reads 10 integer values and stores them in an array....

Q#2
Write a C++ program that reads 10 integer values and stores them in an array. The program should find and display the average of the array elements and how many elements are below the average.

In: Computer Science

Q#3 Write a C++ program to read 10 temperatures in Celsius and to store the temperatures...

Q#3
Write a C++ program to read 10 temperatures in Celsius and to store the temperatures in an array of integers, then it should convert the temperatures to Fahrenheit and store the new values rounded to the nearest integer in another array . The program should display both temperatures in a table form.   
F = 9/5 x C + 32 where F is temp in Fahrenheit and C temperature in Celsius

In: Computer Science

list the different cabling types and their issues (deficiencies) that come up when you use them...

list the different cabling types and their issues (deficiencies) that come up when you use them in a network. What cable works the best or would you suggest and why?

This assignment should be a minimum of one page in length

In: Computer Science

I am to complete the following for Java but getting compiler errors...Implement a base class called...

I am to complete the following for Java but getting compiler errors...Implement a base class called Student that contains a name and major. Implement the subclass GraduateStudent, which adds a property called stipend.

Here is what I have for code with the compiler error following.

public class GraduateStudent extends Student {
  
   private double stipend;
  
   public GraduateStudent(String name, String major, double stipend) {
      
       super(name);
       super(major);
  
       this.stipend = stipend;
      
   }
  
   public void setStipend(double stipend) {
       this.stipend = stipend;
   }
  
   public double getStipend() {
       return stipend;
   }
}

public class Student {
  
protected String name;
protected String major;
  
public Student(String name, String major) {
this.name = name;
this.major = major;
}
  
public void setName(String name) {
this.name = name;
}
  
public String getName() {
return name;
}
  
public void setMajor(String major) {
this.major = major;
}
  
public String getMajor() {
return major;
}
}

GraduateStudent.java:7: error: constructor Student in class Student cannot be applied to given types;
                super(name);
                ^
  required: String,String
  found: String
  reason: actual and formal argument lists differ in length
GraduateStudent.java:8: error: call to super must be first statement in constructor
                super(major);
                     ^
2 errors
[ERROR] did not compile; check the compiler stack trace field for more info

PROGRAM EXECUTION STACK TRACE

[ERROR] did not compile; check the compiler stack trace field for more info

YOUR CODE'S OUTPUT

 
1 [ERROR] did not compile; check the compiler stack trace field for more info
2
3 false

In: Computer Science