Please Make The Following App With Android Studio Using Java: 1.The App Is A Coin Calculator Where The User Will Be Able To Choose How Many Of Each Coin He Has And The App Will Calculate How Many Cents Total That Is. 2. This Should Be Done Using Four Card

匿名用户 最后更新于 2021-12-01 19:36 计算机类Computing

Please make the following app with Android Studio usingJava:
1.The app is a coin calculator where the user will be able tochoose how many of each coin he has and the app will calculate howmany cents total that is.
2. This should be done using four CardViews, one for each of Penny,Nickel, Dime and Quarter.
Each CardView should contain:
a) an ImageView of the coin (from drawables provided)
b) below that, an EditText for the user to type in (numbers only)the amount of that coin

3. Lastly, the app should have a menu with two items:
a) Clear All : Always shown on Toolbar with anicon of your choice
b)About: Never shown on Toolbar; java code to runwhen clicked:

Please make sure it looks exactly like the two imagesside by side below: (right is before the user enterssomething, left is after)

Here is the Java Code for the MVC model. CoinCounter.java:

package com.android.coin_counter;

import com.google.gson.Gson;

public class CoinCounter
{
private int mCountOfPennies, mCountOfNickels, mCountOfDimes,mCountOfQuarters;

public int getCentsValueTotal ()
{
return getCentsValueOfPennies () + getCentsValueOfNickels ()
+ getCentsValueOfDimes () + getCentsValueOfQuarters ();
}

public int getCentsValueOfPennies ()
{
return mCountOfPennies;
}

public int getCentsValueOfNickels ()
{
return mCountOfNickels * 5;
}

public int getCentsValueOfDimes ()
{
return mCountOfDimes * 10;
}

public int getCentsValueOfQuarters ()
{
return mCountOfQuarters * 25;
}


public int getCountOfPennies ()
{
return mCountOfPennies;
}

public void setCountOfPennies (int countOfPennies)
{
this.mCountOfPennies = Math.max(0, countOfPennies);
}

public void setCountOfPennies (String countOfPennies)
{
this.mCountOfPennies = (countOfPennies == null ||countOfPennies.equals (""))
? 0 : Integer.parseInt (countOfPennies);
}

public int getCountOfNickels ()
{
return mCountOfNickels;
}

public void setCountOfNickels (int countOfNickels)
{
this.mCountOfNickels = Math.max(0, countOfNickels);
}

public void setCountOfNickels(String nickels)
{
this.mCountOfNickels = (nickels == null || nickels.equals ("")) ? 0: Integer.parseInt (nickels);
}

public int getCountOfDimes ()
{
return mCountOfDimes;
}

public void setCountOfDimes (int countOfDimes)
{
this.mCountOfDimes = Math.max(0, countOfDimes);
}

public void setCountOfDimes(String dimes)
{
this.mCountOfDimes = (dimes == null || dimes.equals ("")) ? 0 :Integer.parseInt (dimes);
}

public int getCountOfQuarters ()
{
return mCountOfQuarters;
}

public void setCountOfQuarters (int countOfQuarters)
{
this.mCountOfQuarters = Math.max(0, countOfQuarters);
}

public void setCountOfQuarters(String quarters)
{
this.mCountOfQuarters = (quarters == null || quarters.equals (""))? 0 : Integer.parseInt (quarters);
}

public static String getJSONStringFrom (CoinCountercurrentCC)
{
return new Gson ().toJson (currentCC);
}

public String getJSONStringFromThis()
{
return new Gson ().toJson (this);
}


public static CoinCounter getCoinCounterObjectFromJSONString(StringcurrentCC)
{
return new Gson ().fromJson (currentCC, CoinCounter.class);
}

}


Android Emulator - Square_API_29:5556 Android Emulator - Square_API_29:5556 10:33 @ 10:34 Coin Counter CLEAR ALL Coin Counter CLEAR ALL PLEASE ENTER IN THE COIN COUNT: PLEASE ENTER IN THE COIN COUNT: 0 0 0 0 8 6 1 3 SA Total in cents: 123

已邀请: