Help wirh this c# question The trading system used by Incompetent Financial Hold
ID: 664105 • Letter: H
Question
Help wirh this c# question
The trading system used by Incompetent Financial Holdings, Inc. (IFH) keeps track of a customer's stock holdings using four pieces of data: (1) stock ticker symbol, (2) the purchase price of a stock, (3) the current daily price of the stock, and (4) the number of shares of the stock held by the customer. The system needs to be able to keep track of the cost in dollars and value in dollars of the holding.
IFH also allows customers to keep non-US stocks in their portfolios. The same information is maintained for foreign stock holdings as with domestic stocks (with any monetary data stored in the foreign currency) with the addition of keeping track of the conversion rate between the foreign currency and the domestic currency.
Design and implement two classes that keep track of both types of stock holdings. Your class for foreign stocks should inherit its behavior from the base stock holding class. The base class needs to provide a virtual method for printing the value of the stock that will be overrode by the foreign stock. The override method in the foreign stock will need to compute the value of the stock in dollars using the conversion rate and print the value of that stock in both the domestic and foreign currencies.
NOTE: you do not need to implement a Main() method for these classes (you will use them in the next question).
Explanation / Answer
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static bool IsPalindrome(string src)
{
bool palindrome = true;
for (int i = 0; i < src.Length / 2 + 1; i++)
{
if (src[i] != src[src.Length - i - 1])
{
palindrome = false;
break;
}
}
return palindrome;
}
static void Main(string[] args)
{
Console.Write("Enter a String: ");
string s = Console.ReadLine();
if (IsPalindrome(s) == true)
{
Console.WriteLine(s + " is a palindrome");
}
else
{
Console.WriteLine(s + " is NOT a palindrome");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static bool IsPalindrome(string src)
{
bool palindrome = true;
for (int i = 0; i < src.Length / 2 + 1; i++)
{
if (src[i] != src[src.Length - i - 1])
{
palindrome = false;
break;
}
}
return palindrome;
}
static void Main(string[] args)
{
Console.Write("Enter a String: ");
string s = Console.ReadLine();
if (IsPalindrome(s) == true)
{
Console.WriteLine(s + " is a palindrome");
}
else
{
Console.WriteLine(s + " is NOT a palindrome");
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.