online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ public class Main { public static void main(String[] args) { UsedCarLot u=new UsedCarLot(); u.printAllSales(); System.out.println("avg profit is "+u.findAvgProfit()); u.printWorkerSales("Abdullahi"); u.deleteWorkerSales("Will"); u.printAllSales(); u.decreaseAllSalePrice(); System.out.println(u.findSale(4580)); if (u.getTopSales(2000)!=null) for (Sale s:u.getTopSales(2000)) System.out.println(s); //ADVANCED BELOW u.sortByProfit(); u.printAllSales(); } }
/** * This class will keep track of the sale of a used car * * @author Jeff Borland * @version 1.08 */ public class Sale { private String sellerName; private int salePrice; private int carValue; private int profit; private int date; //in format 20080212 yyyymmdd public Sale (int date, String sellerName, int salePrice, int carValue) { this.date=date; this.sellerName=sellerName; this.salePrice=salePrice; this.carValue=carValue; profit=salePrice-carValue; } public String getSellerName() { return sellerName; } public int getDate() { return date; } public int getSalePrice() { return salePrice; } public void setSalePrice(int salePrice) { this.salePrice = salePrice; } public int getCarValue() { return carValue; } public int getProfit() { profit=salePrice-carValue; return profit; } @Override public String toString() { return "Sale [sellerName=" + sellerName + ", salePrice=" + salePrice + ", carValue=" + carValue + ", profit=" + profit + ", date=" + date + "]"; } }
/** * A class to practice arraylist of objects (of sales) * * @author (your name) * @version (a version number or a date) */ import java.io.File; import java.io.IOException; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Scanner; public class UsedCarLot { private ArrayList<Sale> allSales=new ArrayList<Sale>(); public UsedCarLot() { initializeSales(); //initalizes allSales } //The method below will initialize the 50 sales from the text file public void initializeSales() { try { Scanner scan=new Scanner(new File("sales.txt")); while (scan.hasNext()) { String theLine=scan.nextLine(); //This reads in the next player line String[] splits=theLine.split(","); allSales.add(new Sale(Integer.parseInt(splits[0]),splits[1],Integer.parseInt(splits[2]),Integer.parseInt(splits[3]))); System.out.print("r"); } System.out.println(); } catch (IOException e){ System.out.print("Trouble reading"); } } public void printAllSales () { System.out.println("Print"); } public void printWorkerSales (String workersName) { } public double findAvgProfit() { return 0; } public void deleteWorkerSales (String workersName) { } public void decreaseAllSalePrice() { } public Sale findSale (int salePrice) { return null; } public ArrayList<Sale> getTopSales (int profit) { return null; } public void sortByProfit() { } /********* * BELOW FOR teacher purposes only. */ //The method below will initialize 50 sales randomly public static void randomSales() { int DEFAULTNUMOFSALES=50; String[] employees={"Ben","Logan", "Darcy", "Abdullahi", "Will"}; NumberFormat twoDigits=NumberFormat.getIntegerInstance(); for (int i=0; i<DEFAULTNUMOFSALES; i++) { String randomEmployee=employees[(int)(Math.random()*5)]; twoDigits.setMinimumIntegerDigits(2); String randomDateString=""+((int)(Math.random()*3)+2016)+twoDigits.format(((int)(Math.random()*12)+1))+twoDigits.format(((int)(Math.random()*31)+1)); int randomDate=Integer.parseInt(randomDateString); int salePrice=(int)(Math.random()*15500+1400); int carValue=salePrice-((int)(Math.random()*3500)-500); System.out.println (randomDate+","+ randomEmployee+","+salePrice+","+carValue); } } }
20160204,Will,13024,10285 20180911,Abdullahi,12478,11321 20170312,Darcy,11761,12233 20170405,Logan,15612,14760 20170115,Abdullahi,7330,6630 20180805,Will,10615,10360 20170630,Abdullahi,10167,8281 20180713,Darcy,5876,5827 20170211,Will,10465,8053 20180928,Logan,16294,14042 20180828,Darcy,2415,2547 20161107,Will,3482,896 20170909,Darcy,8028,5721 20171209,Abdullahi,5905,5431 20180723,Darcy,15116,12821 20170227,Logan,7711,4842 20181214,Ben,6702,6647 20160410,Abdullahi,15264,13047 20171113,Abdullahi,11752,10802 20180318,Will,3762,2229 20181013,Darcy,16167,14276 20170821,Darcy,9448,7843 20170902,Ben,10547,10334 20171115,Logan,9746,7304 20170703,Logan,6663,6845 20160713,Darcy,4657,1680 20170826,Logan,16057,15863 20161126,Abdullahi,4995,4907 20170402,Logan,7546,4891 20170516,Darcy,3929,1159 20180909,Darcy,9253,8464 20160606,Abdullahi,16480,14208 20170716,Logan,4580,3285 20181211,Will,9900,10217 20160209,Will,12288,11853 20160329,Darcy,8434,7614 20170231,Darcy,10550,10668 20171126,Logan,9681,7316 20170914,Abdullahi,15467,12717 20161002,Will,14720,14733 20170928,Logan,5697,5164 20170319,Will,16808,15655 20160311,Abdullahi,7344,7768 20160829,Ben,11812,12273 20160320,Darcy,6307,4738 20170318,Will,11071,10225 20180514,Darcy,11743,10385 20160930,Logan,10656,8747 20160317,Logan,12197,12083 20170602,Darcy,8438,6127

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue