I need help in the following C# programming:


Vehicle manufacturers always offer new saving fuel cars to new drivers. The Renault manufacturer has taken this in consideration and offered new car Renault Clio to a driver Syle LeSylani for one year use. Syle has kept evidence of past kilometers at every fuel filling. He made at least 5 reservoirs filling per year.

My duty is to write the C# program that it will accept fuel data (type: double) and past kilometers (type: double) for every fuel filling. The program it needs to process those data in console application, how many kilometers are past in each filling. Also it needs to show overall calculation of past kilometers for all fillings. The calculation must be presented in decimal (real numbers). The class and the program should be in two separate files.

Please if you can help me or just to give me a suggestion how to begin this because accrding to my acknowledge here something is missing.
Also i need to make the algorythm of it.

In advance thank you for your reply.
Cheers.

OK, firstly, does the program need to save the entered data each time or does the user simply enter all past fuels fills at the one time to get the average? The answer to this question determines whether you need to use a file to save the information.

The algorithms are fairly simple. For each fuel fill it is kms done / number of litres of fuel to give kms per litre. Overall distance is the same but including all of the data.

OK, firstly, does the program need to save the entered data each time or does the user simply enter all past fuels fills at the one time to get the average? The answer to this question determines whether you need to use a file to save the information.

The algorithms are fairly simple. For each fuel fill it is kms done / number of litres of fuel to give kms per litre. Overall distance is the same but including all of the data.

Yes, the program needs to save the entered data each time.

Store the fuel and distance data in a text file (or database).
Make the class read and calculate the data.

Have you started on any of this, yet?
Do you have the data file ready?

As I mentioned in my first post, those data must be shown in Console Application and I have to make two separate files where one is the main program file and other file is Class file.
I don't have a clue how to make this, because I'm a beginer.

@ thines01
About your questions, the answer is negative.

Cheers.

Can you post a couple of the lines of the data?

First of all my mother tongue is Albanian so you just can understand the program and not the text.
The main program is this

namespace Detyra3_1
{
    class Program
    {
        static void Main(string[] args)
        {
            KlasaIme kIme = new KlasaIme();
            kIme.TestHarxhimi();   
        }
    }

    class KlasaIme
    {
        double kilometrat;
        double rezervuari;
        double mbushjet;
        int numriMbushjeve;
        double hyrjet;

        public double Kilometrat
        {
            set
            {
                kilometrat = value;
            }
            get
            {
                return kilometrat;
            }
        }

        public double Rezervuari
        {
            set
            {
                rezervuari = value;
            }
            get
            {
                return rezervuari;
            }
        }

        public double Mbushjet
        {
            set
            {
                mbushjet = mbushjet + value;
            }
            get
            {
                return mbushjet;
                numriMbushjeve = numriMbushjeve + 1;
            }
        }

        public int NumriMbushjeve
        {
            set
            {
              //
            }
            get
            {
                return numriMbushjeve;
            }
        }

        public void TestHarxhimi()
        {
            Console.WriteLine("Mire se vini ne Testimin e harxhimit te karburanteve per Renault Clio");
            bool flag1 = true;
            do
            {
                Console.WriteLine("\n Cfar deshironi? \n (1)-Futje Shenimesh \n (2)-Raport \n (3)-Llogaritjet");
                hyrjet = double.Parse(Console.ReadLine());
                if (hyrjet == 1)
                {
                    FutjeShenimesh();
                }
                else if (hyrjet == 2)
                {
                    Raport();
                }
                else if (hyrjet == 3)
                {
                    Llogaritjet();
                }

            } while (flag1);
        }

        public void Llogaritjet()
        {
            bool flag1 = true;
            do
            {
                Console.WriteLine("\n Cfar deshironi? \n (1)-Llogarit se sa kilometra shpenzohen per nje liter derivat! \n (2)-Llogarit se sa kilometra  \n (3)-Trego mbushjet totale te rezervuarit \n (4)-Trego numrin e mbushjeve te rezervuarit \n (-1)<-Kthehu ne menyn kryesore");
                hyrjet = double.Parse(Console.ReadLine());
                if (hyrjet == 1)
                {
                    Console.WriteLine((Mbushjet - Rezervuari) / Kilometrat);
                }
                else if (hyrjet == 2)
                {
                    Console.WriteLine(kilometrat / (mbushjet - rezervuari));
                }
                else if (hyrjet == 3)
                {
                    Console.WriteLine("Totali ne i mbushjeve ne litra " +Mbushjet);
                }
                else if (hyrjet == 4)
                {
                    Console.WriteLine("Numri i mbushjeve: " + NumriMbushjeve);
                }
                else if (hyrjet == -1)
                {
                    flag1 = false;
                }

            } while (flag1);
        }

        public void Raport()
        {
            bool flag1 = true;
            do
            {
                Console.WriteLine("\n Cfar deshironi? \n (1)-Trego kilometrat aktuale \n (2)-Trego gjendjen e rezervuarit \n (3)-Trego mbushjet totale te rezervuarit \n (-1)<-Kthehu ne menyn kryesore");
                hyrjet = double.Parse(Console.ReadLine());
                if (hyrjet == 1)
                {
                    Console.WriteLine(Kilometrat);
                }
                else if (hyrjet == 2)
                {
                    Console.WriteLine(Rezervuari);
                }
                else if (hyrjet == 3)
                {
                    Console.WriteLine(Mbushjet);

                }
                else if (hyrjet == -1)
                {
                    flag1 = false;
                }

            } while (flag1);

        }


        public void FutjeShenimesh()
        {
            bool flag1 = true;
            do
            {
                Console.WriteLine("\n Cfar deshironi? \n (1)-Futje te kilometave te kaluara \n (2)-Futje te gjendjes se rezervuarit \n (3)-Mbushje te rezervuarit \n (-1)<-Mbyllje");
                hyrjet = double.Parse(Console.ReadLine());
                if (hyrjet == 1)
                {
                    FutjeKilometrave();
                }
                else if (hyrjet == 2)
                {
                    FutjeRezervuarit();
                }
                else if (hyrjet == 3)
                {
                    FutjeDerivatit();

                }
                else if (hyrjet == -1)
                {
                    flag1 = false;
                }

            } while (flag1);

        }

        public void FutjeKilometrave()
        {
            bool flag = true;
            do
            {
                Console.WriteLine("Shkruani numrin e kilometrave aktuale");
                hyrjet = double.Parse(Console.ReadLine());
                if (hyrjet >= kilometrat)
                {
                    kilometrat = hyrjet;
                    break;
                }
            } while (flag);

        }

        public void FutjeRezervuarit()
        {
            bool flag = true;
            do
            {
                Console.WriteLine("Shkruani gjendjen aktuale te litrave te rezervuarit");
                hyrjet = double.Parse(Console.ReadLine());
                if (hyrjet >= 0)
                {
                    rezervuari = hyrjet;
                    break;
                }
            } while (flag);
        }

        public void FutjeDerivatit()
        {
            bool flag = true;
            do
            {
                Console.WriteLine("Shkruani numrin e litrave qe doni ti shtoni");
                hyrjet = double.Parse(Console.ReadLine());
                if (hyrjet >= 0)
                {
                    Mbushjet = hyrjet;
                    break;
                }
            } while (flag);
        }
    }
}

About the class i made this:

namespace Detyra3_1
{
    class LlogaritShpenzimet
    {
        double kilometrat = 0;
        double rezervuari = 0;
        double mbushjet = 0;
        public void MbledhjeInformatash(double kmAktuale, double rezervuariAktual, double litraPlus)
        {
            kilometrat = kmAktuale;
            rezervuari = rezervuariAktual;
            mbushjet = mbushjet + litraPlus;
        }

        public double LlogaritLitraPerKilometer(double kilometrat, double rezervuari, double mbushjet)
        {
            return kilometrat / (mbushjet - rezervuari);
        }

        public double LlogaritKilometerPerLiter(double kilometrat, double rezervuari, double mbushjet)
        {

            return (mbushjet - rezervuari) / kilometrat;
        }

        public double Kilometrat
        {
            get
            {
                return kilometrat;
            }
            set
            {
                kilometrat = value;
            }
        }

        public double Rezervuari
        {
            get
            {
                return rezervuari;
            }
            set
            {
                rezervuari = value;
            }
        }

        public double Mbushjet
        {
            get
            {
                return mbushjet;
            }
            set
            {
                mbushjet = value;
            }
        }
    }
}

I meant the data. The values to be read into the program.

Kilometers and liters
Kilometer must be shown every time that we fill with fuel and in that time the console application mus show the result about how many kilometers has past with one liter.
At the begining while the car is new we havre to suggest that kilometers and liters are empty, zero. Any suggestion.

Is the user typing in the data as the program runs or are you reading it from a file?

If you are reading it from a file:
Can you post a couple of the lines of the data (from the file)?

As the program runs the usetr must input the data, while the car is a new car we suppose that kilometers and fuel are zero.
At least 5 fuel filling have to be done in one year.

Cheers.

OK. I understand.

At some point, you will need to save the input data to a repository (file or database or memory) because you are supposed to keep track of the history of the car.

You will also need to retrieve the data from the repository.
That stored data will need a format maybe consisting of
1) The date entered
2) the kilometers
3) the fuel fillings

I see that you have created that but can't tell if you're keeping the date.
You should add a DateTime property to that class.

how?

First, I would start with a class that looks like this:

using System;

namespace DW_402947_CON
{
   public class CEfficiencyInfo
   {
      public double dblKilometers { get; set; }
      public double dblFuelLiters { get; set; }
      public DateTime dtEntryDate { get; set; }

      public CEfficiencyInfo()
      {
         dblKilometers = 0.0;
         dblFuelLiters = 0.0;
         dtEntryDate = DateTime.Now;
      }

      public CEfficiencyInfo(CEfficiencyInfo copy)
      {
         dblKilometers = copy.dblKilometers;
         dblFuelLiters = copy.dblFuelLiters;
         dtEntryDate = copy.dtEntryDate;
      }

      public CEfficiencyInfo(double dblKilos, double dblFuel, DateTime dtEntryDate)
      {
         this.dblKilometers = dblKilos;
         this.dblFuelLiters = dblFuel;
         this.dtEntryDate = dtEntryDate;
      }

      public override string ToString()
      {
         return
            dblKilometers.ToString() + '-' +
            dblFuelLiters.ToString() + '-' +
            dtEntryDate.ToOADate().ToString();
      }

      public override bool Equals(object obj)
      {
         return this.ToString().Equals(((CEfficiencyInfo)obj).ToString());
      }

      public override int GetHashCode()
      {
         return this.ToString().GetHashCode();
      }

      public double KpL()
      {
         return dblKilometers / dblFuelLiters;
      }
   }
}
commented: Cheers for your help, problem solved. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.