Dinny
input file error
when reading numbers in my input file, i convert them to integers and assign specific numbers to a variable such as
but i keep getting an error saying "'Input string was not in a correct format.'" i am unsure how to fix this because the input file is automatically a string, but converting it to an int is causing an error. I normally convert this way and have not had an issue
222 replies
I am unaware on how to fix this conversion error
it's saying i can't convert from string to int, though I am unsure why when i used the string.format method to represent my int variable ID as a string and display it in my output file. I have three separte files for a regular user logging in, an administrator, and thena file to put the whole program together.
here is admin and the full program since that is where the issue lies
108 replies
✅ Reading matricies to an output file
I am trying to read the data inside two matricies from an input file firstly in order to add them together and display the result to the output file. Before I get to that, I am struggling trying to get the program to read each row and column. Here's the block of code with my errors
I have a red line where it says " a[rowIndex, j] = int.Parse(nextLine[j]); and the error reads "Cannot apply indexing [] to an expression of type "Matrix.Matricies."
7 replies
Overloading "+" operator
I am adding fractions together and need to overload the plus operator, but I keep running into an error while I am building the code. Before even adding them together, he wants us to find the GCD (greatest common denom) to simplfy the fractions down before adding them together, which is where my error arises.
I get an error under "denominator" after the "Math.Abs(numerator)" and when dividing the denominator by the GCD
46 replies
are my getters and setters correct?
Before I work on the rest of my code, please let me know if there are any errors in my getters and setters
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Menu
{
private string dishName;
private int dishType, dishPrice;
//def constructor
class Menu() { }
//const with param
public Menu(String dishName, int dishType, int dishPrice)
{
SetName(dishName);
SetType(dishType);
SetPrice(dishType);
}
//GETTERS
/ Returns the name of the dish.
@return: dish name
*/
public void GetName() { return dishName; }
/ Returns the type of dish ordered.
@return: returns either appetizer, entree, or dessert
*/
public int GetType() { return dishType; }
/ Returns the height of the rectangle.
@return: height of the rectangle
*/
public interface GetPrice() { returns dishPrice; }
//SETTERS
/ Updates name of dish.
@param width: the updated dish name
*/
public void SetName(string dishName) { this.Name = dishName; }
/ Updates the type of dish.
@param width: the updated dish type
*/
public void SetType(string dishType) { this.Type = dishType; }
/ Updates the type of dish.
@param width: the updated dish type
*/
public void SetPrice(string dishPrice) { this.Price = dishPrice; }
public override string ToString() { return string.Format(dishName + "(" + dishPrice + ")", GetName(), GetPrice()); }
}
278 replies