Question

In: Computer Science

using xml, Create a number guessing game You would need an input box and buttons Ask...

using xml, Create a number guessing game

You would need an input box and buttons

Ask the user for a number

Produce a random number from 1-50

Do the comparison

            a. Make sure to provide hints back to the user if the number enter is low or high

                        -this element should be automatically added

            b. Clear the value enter in the text

            c. Give them 3 tries

Whether the user wins or loses, display all the guesses along with the actual number with

congrats or try again message

            -after the message, allow them to play again

Solutions

Expert Solution

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity">

    <RelativeLayout

        android:layout_width="409dp"

        android:layout_height="729dp"

        android:background="#F3A68E"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintEnd_toEndOf="parent"

        app:layout_constraintHorizontal_bias="1.0"

        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintTop_toTopOf="parent">

        <TextView

            android:id="@+id/textView"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentStart="true"

            android:layout_alignParentLeft="true"

            android:layout_alignParentTop="true"

            android:layout_marginStart="77dp"

            android:layout_marginLeft="77dp"

            android:layout_marginTop="47dp"

            android:background="#FF9100"

            android:text="GUESS THE NUMBER"

            android:textSize="30sp" />

        <TextView

            android:id="@+id/textView2"

            android:layout_width="391dp"

            android:layout_height="68dp"

            android:layout_alignParentStart="true"

            android:layout_alignParentLeft="true"

            android:layout_alignParentTop="true"

            android:layout_marginStart="21dp"

            android:layout_marginLeft="21dp"

            android:layout_marginTop="147dp"

            android:text="I am thinking a number between 1 to 100. Can you guess what it is ?"

            android:textSize="24sp"

            app:layout_constraintEnd_toEndOf="parent"

            app:layout_constraintStart_toStartOf="parent" />

        <EditText

            android:id="@+id/editId"

            android:layout_width="348dp"

            android:layout_height="67dp"

            android:layout_alignParentTop="true"

            android:layout_alignParentEnd="true"

            android:layout_alignParentRight="true"

            android:layout_marginTop="271dp"

            android:layout_marginEnd="30dp"

            android:layout_marginRight="30dp"

            android:ems="10"

            android:gravity="center"

            android:hint="ENTER"

            android:inputType="numberDecimal" />

        <Button

            android:id="@+id/button"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentEnd="true"

            android:layout_alignParentRight="true"

            android:layout_alignParentBottom="true"

            android:layout_marginEnd="152dp"

            android:layout_marginRight="152dp"

            android:layout_marginBottom="266dp"

            android:onClick="clickFunction"

            android:text="GUESS"

            android:textSize="30sp"

            app:layout_constraintEnd_toEndOf="parent"

            app:layout_constraintStart_toStartOf="parent" />

    </RelativeLayout>

</androidx.constraintlayout.widget.constraingLayout>


Related Solutions

using xsd, Create a number guessing game You would need an input box and buttons Ask...
using xsd, Create a number guessing game You would need an input box and buttons Ask the user for a number Produce a random number from 1-50 Do the comparison ​a. Make sure to provide hints back to the user if the number enter is low or high ​​-this element should be automatically added ​b. Clear the value enter in the text ​c. Give them 3 tries Whether the user wins or loses, display all the guesses along with the...
guessing game in Java. It will have a guess input used for guessing the random number...
guessing game in Java. It will have a guess input used for guessing the random number that is generated from 1 - 100. When the user makes a guess it will tell them if the number is lower or higher than the guess. There is also a choice to give up which then reveals the correct number. The last choice will be new game which resets the random number. Last, the program should keep counts of tries. When the user...
1. [100] Create a C program for a number guessing game. Here are the requirements: a....
1. [100] Create a C program for a number guessing game. Here are the requirements: a. Your program generates a random number between -100 and 100 and keeps asking the user to guess the number until the user guesses it correctly. Your random number generator should be implemented as a C function which takes min and max values as input parameters and returns a random number between those values including the min and the max. b. If the user guesses...
Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10....
Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10. Have the user guess the number. If it is too high, tell the user to guess lower - it it is too low, tell the user to guess higher. Continue until she guesses the correct number. - Part 2. Allow the user to play a new game after they have guessed correctly.   Part 3. Ask for a different name and keep track of how...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1 and 100. Console Welcome to the Guess the Number Game ++++++++++++++++++++++++++++++++++++ I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 You got it in 1 tries. Great work! You are a mathematical wizard. Try again? (y/n): y I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 Way too high! Guess...
Part (a) Write a number guessing game using System.Collections.Generic.Dictionary. Generate 10 distinct random numbers in the...
Part (a) Write a number guessing game using System.Collections.Generic.Dictionary. Generate 10 distinct random numbers in the range of 1 to 20. Each random number is associated with a prize money (from 1 to 10000). Use a Dictionary to store the mapping between the random number and the prize money. Ask user for two distinct numbers, a and b, both from 1 to 20; if a and b are not distinct, or out of range, quit the program Lookup the prize...
Please Use JavaScript and HTML 5) Number guesser (easier) Create a number guessing name, using an...
Please Use JavaScript and HTML 5) Number guesser (easier) Create a number guessing name, using an input and a button to gather a number. The number to be guessed should be a hard-coded whole number between 1 and 20. Tell the user if the number is too high, equal to, or too low than a number you have hard-coded in your application. Remove the text in the input when the user clicks the button.
Number guessing Game (20 Marks) Write a C program that implements the “guess my number” game....
Number guessing Game Write a C program that implements the “guess my number” game. The computer chooses a random number using the following random generator function srand(time(NULL)); int r = rand() % 100 + 1; that creates a random number between 1 and 100 and puts it in the variable r. (Note that you have to include <time.h>) Then it asks the user to make a guess. Each time the user makes a guess, the program tells the user if...
This is an XML exercise. Explain why you need LINQ to XML.
This is an XML exercise. Explain why you need LINQ to XML.
Create a simple shopping cart application. Ask the user to input an item number and quantity....
Create a simple shopping cart application. Ask the user to input an item number and quantity. Update the shopping cart. Display the updated cart. Include the following when displaying cart: item number, name, quantity and total price. Ask for another update or end the program. Design Requires 2 classes: the main class and the cartItem class In the main class: Need one array named cartArray of type cartItem. Size = ? Need a loop that asks the user for input....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT